summaryrefslogtreecommitdiffstats
path: root/src/event-loop.c
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@bitplanet.net>2012-05-08 10:42:42 -0400
committerKristian Høgsberg <krh@bitplanet.net>2012-05-08 10:42:42 -0400
commitc49f632dae67ee3055e4874f028f723663486da6 (patch)
tree1b8b9d6da272385d3e2010ed9ef7d4f5c4bfe7d7 /src/event-loop.c
parenttests: prefix event loop tests with event_loop_ (diff)
downloadwayland-c49f632dae67ee3055e4874f028f723663486da6.tar
wayland-c49f632dae67ee3055e4874f028f723663486da6.tar.gz
wayland-c49f632dae67ee3055e4874f028f723663486da6.tar.bz2
wayland-c49f632dae67ee3055e4874f028f723663486da6.tar.lz
wayland-c49f632dae67ee3055e4874f028f723663486da6.tar.xz
wayland-c49f632dae67ee3055e4874f028f723663486da6.tar.zst
wayland-c49f632dae67ee3055e4874f028f723663486da6.zip
event-loop: Delete fd from epoll when removing event source
Closing an fd will remove it from the epoll set only if it hasn't been dup'ed. In other words, the fd is only removed from epoll when all file descriptors referring to the open file has been close. We now dup fd for fd sources, so we need to use EPOLL_CTL_DEL directly now.
Diffstat (limited to 'src/event-loop.c')
-rw-r--r--src/event-loop.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/event-loop.c b/src/event-loop.c
index b881a0d..a839daf 100644
--- a/src/event-loop.c
+++ b/src/event-loop.c
@@ -309,10 +309,14 @@ wl_event_source_remove(struct wl_event_source *source)
{
struct wl_event_loop *loop = source->loop;
- if (source->fd >= 0)
+ /* We need to explicitly remove the fd, since closing the fd
+ * isn't enough in case we've dup'ed the fd. */
+ if (source->fd >= 0) {
+ epoll_ctl(loop->epoll_fd, EPOLL_CTL_DEL, source->fd, NULL);
close(source->fd);
+ source->fd = -1;
+ }
- source->fd = -1;
wl_list_remove(&source->link);
wl_list_insert(&loop->destroy_list, &source->link);