mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-11 23:16:14 +01:00
Reorder operations in _kqsub_cancel() to prevent races.
Removing the event and closing the related file descriptor must be done first to make sure the kqueue subsystem delete pending events. The timeout must be disarmed before freeing the directory dependency list otherwise it might populate it again. https://bugzilla.gnome.org/show_bug.cgi?id=795193
This commit is contained in:
parent
1217b1bc4f
commit
ab179184b8
@ -373,28 +373,28 @@ _kqsub_cancel (kqueue_sub *sub)
|
||||
{
|
||||
struct kevent ev;
|
||||
|
||||
/* Remove the event and close the file descriptor to automatically
|
||||
* delete pending events. */
|
||||
if (sub->fd != -1)
|
||||
{
|
||||
EV_SET (&ev, sub->fd, EVFILT_VNODE, EV_DELETE, NOTE_ALL, 0, sub);
|
||||
if (kevent (kq_queue, &ev, 1, NULL, 0, NULL) == -1)
|
||||
{
|
||||
g_warning ("Unable to remove event for %s: %s", sub->filename, g_strerror (errno));
|
||||
return FALSE;
|
||||
}
|
||||
close (sub->fd);
|
||||
sub->fd = -1;
|
||||
}
|
||||
|
||||
_km_remove (sub);
|
||||
|
||||
if (sub->deps)
|
||||
{
|
||||
dl_free (sub->deps);
|
||||
sub->deps = NULL;
|
||||
}
|
||||
|
||||
_km_remove (sub);
|
||||
|
||||
/* Only in the missing list? We're done! */
|
||||
if (sub->fd == -1)
|
||||
return TRUE;
|
||||
|
||||
EV_SET (&ev, sub->fd, EVFILT_VNODE, EV_DELETE, NOTE_ALL, 0, sub);
|
||||
if (kevent (kq_queue, &ev, 1, NULL, 0, NULL) == -1)
|
||||
{
|
||||
g_warning ("Unable to remove event for %s: %s", sub->filename, g_strerror (errno));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
close (sub->fd);
|
||||
sub->fd = -1;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user