mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-11-01 22:58:40 -04:00
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.
This commit is contained in:
parent
f42d763cd0
commit
c49f632dae
1 changed files with 6 additions and 2 deletions
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue