… | |
… | |
119 | epoll_poll (EV_P_ ev_tstamp timeout) |
119 | epoll_poll (EV_P_ ev_tstamp timeout) |
120 | { |
120 | { |
121 | int i; |
121 | int i; |
122 | int eventcnt; |
122 | int eventcnt; |
123 | |
123 | |
|
|
124 | /* epoll wait times cannot be larger than (LONG_MAX - 999UL) / HZ msecs, which is below */ |
|
|
125 | /* the default libev max wait time, however. */ |
124 | EV_RELEASE_CB; |
126 | EV_RELEASE_CB; |
125 | eventcnt = epoll_wait (backend_fd, epoll_events, epoll_eventmax, (int)ceil (timeout * 1000.)); |
127 | eventcnt = epoll_wait (backend_fd, epoll_events, epoll_eventmax, (int)ceil (timeout * 1000.)); |
126 | EV_ACQUIRE_CB; |
128 | EV_ACQUIRE_CB; |
127 | |
129 | |
128 | if (expect_false (eventcnt < 0)) |
130 | if (expect_false (eventcnt < 0)) |
… | |
… | |
157 | /* we received an event but are not interested in it, try mod or del */ |
159 | /* we received an event but are not interested in it, try mod or del */ |
158 | /* I don't think we ever need MOD, but let's handle it anyways */ |
160 | /* I don't think we ever need MOD, but let's handle it anyways */ |
159 | ev->events = (want & EV_READ ? EPOLLIN : 0) |
161 | ev->events = (want & EV_READ ? EPOLLIN : 0) |
160 | | (want & EV_WRITE ? EPOLLOUT : 0); |
162 | | (want & EV_WRITE ? EPOLLOUT : 0); |
161 | |
163 | |
|
|
164 | /* pre-2.6.9 kernels require a non-null pointer with EPOLL_CTL_DEL, */ |
|
|
165 | /* which is fortunately easy to do for us. */ |
162 | if (epoll_ctl (backend_fd, want ? EPOLL_CTL_MOD : EPOLL_CTL_DEL, fd, ev)) |
166 | if (epoll_ctl (backend_fd, want ? EPOLL_CTL_MOD : EPOLL_CTL_DEL, fd, ev)) |
163 | { |
167 | { |
164 | postfork = 1; /* an error occured, recreate kernel state */ |
168 | postfork = 1; /* an error occured, recreate kernel state */ |
165 | continue; |
169 | continue; |
166 | } |
170 | } |