eloop: remove fd from epoll-set on HUP

If a handler does not correctly remove itself on HUP, the epoll-loop will
never sleep again because the fd will always be notified as HUP.
Therefore, remove the fd from the epoll-set directly on HUP. This doesn't
change application behavior so it is safe here.

This also allows other subsystems to ignore HUP/ERR events if they are not
fatal. The FD won't be readded but that may not bother.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This commit is contained in:
David Herrmann 2012-03-23 16:59:42 +01:00
parent 56659ce429
commit 563492a0c8

View File

@ -798,10 +798,12 @@ int ev_eloop_dispatch(struct ev_eloop *loop, int timeout)
mask |= EV_READABLE;
if (ep[i].events & EPOLLOUT)
mask |= EV_WRITEABLE;
if (ep[i].events & EPOLLHUP)
mask |= EV_HUP;
if (ep[i].events & EPOLLERR)
mask |= EV_ERR;
if (ep[i].events & EPOLLHUP) {
mask |= EV_HUP;
epoll_ctl(loop->efd, EPOLL_CTL_DEL, fd->fd, NULL);
}
fd->cb(fd, mask, fd->data);
}