From 2edf70eb0c471cff2fadb157ea3fe1592d9b3cd4 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 27 Jun 2011 21:51:52 +0000 Subject: *** empty log message *** --- ev_epoll.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/ev_epoll.c b/ev_epoll.c index f9e3fd7..58bf9b9 100644 --- a/ev_epoll.c +++ b/ev_epoll.c @@ -170,8 +170,12 @@ epoll_poll (EV_P_ ev_tstamp timeout) int got = (ev->events & (EPOLLOUT | EPOLLERR | EPOLLHUP) ? EV_WRITE : 0) | (ev->events & (EPOLLIN | EPOLLERR | EPOLLHUP) ? EV_READ : 0); - /* check for spurious notification */ - /* we assume that fd is always in range, as we never shrink the anfds array */ + /* + * check for spurious notification. + * this only finds spurious notifications on egen updates + * other spurious notifications will be found by epoll_ctl, below + * we assume that fd is always in range, as we never shrink the anfds array + */ if (expect_false ((uint32_t)anfds [fd].egen != (uint32_t)(ev->data.u64 >> 32))) { /* recreate kernel state */ @@ -183,8 +187,15 @@ epoll_poll (EV_P_ ev_tstamp timeout) { anfds [fd].emask = want; - /* we received an event but are not interested in it, try mod or del */ - /* I don't think we ever need MOD, but let's handle it anyways */ + /* + * we received an event but are not interested in it, try mod or del + * this often happens because we optimistically do not unregister fds + * when we are no longer interested in them, but also when we get spurious + * notifications for fds from another process. this is partially handled + * above with the gencounter check (== our fd is not the event fd), and + * partially here, when epoll_ctl returns an error (== a child has the fd + * but we closed it). + */ ev->events = (want & EV_READ ? EPOLLIN : 0) | (want & EV_WRITE ? EPOLLOUT : 0); -- cgit v1.2.3