… | |
… | |
201 | |
201 | |
202 | /* pre-2.6.9 kernels require a non-null pointer with EPOLL_CTL_DEL, */ |
202 | /* pre-2.6.9 kernels require a non-null pointer with EPOLL_CTL_DEL, */ |
203 | /* which is fortunately easy to do for us. */ |
203 | /* which is fortunately easy to do for us. */ |
204 | if (epoll_ctl (backend_fd, want ? EPOLL_CTL_MOD : EPOLL_CTL_DEL, fd, ev)) |
204 | if (epoll_ctl (backend_fd, want ? EPOLL_CTL_MOD : EPOLL_CTL_DEL, fd, ev)) |
205 | { |
205 | { |
206 | postfork = 1; /* an error occurred, recreate kernel state */ |
206 | postfork |= 2; /* an error occurred, recreate kernel state */ |
207 | continue; |
207 | continue; |
208 | } |
208 | } |
209 | } |
209 | } |
210 | |
210 | |
211 | fd_event (EV_A_ fd, got); |
211 | fd_event (EV_A_ fd, got); |
… | |
… | |
233 | anfds [fd].emask = 0; |
233 | anfds [fd].emask = 0; |
234 | } |
234 | } |
235 | } |
235 | } |
236 | } |
236 | } |
237 | |
237 | |
238 | int inline_size |
238 | inline_size |
|
|
239 | int |
239 | epoll_init (EV_P_ int flags) |
240 | epoll_init (EV_P_ int flags) |
240 | { |
241 | { |
241 | #ifdef EPOLL_CLOEXEC |
242 | #if defined EPOLL_CLOEXEC && !defined __ANDROID__ |
242 | backend_fd = epoll_create1 (EPOLL_CLOEXEC); |
243 | backend_fd = epoll_create1 (EPOLL_CLOEXEC); |
243 | |
244 | |
244 | if (backend_fd < 0 && (errno == EINVAL || errno == ENOSYS)) |
245 | if (backend_fd < 0 && (errno == EINVAL || errno == ENOSYS)) |
245 | #endif |
246 | #endif |
246 | backend_fd = epoll_create (256); |
247 | backend_fd = epoll_create (256); |
… | |
… | |
258 | epoll_events = (struct epoll_event *)ev_malloc (sizeof (struct epoll_event) * epoll_eventmax); |
259 | epoll_events = (struct epoll_event *)ev_malloc (sizeof (struct epoll_event) * epoll_eventmax); |
259 | |
260 | |
260 | return EVBACKEND_EPOLL; |
261 | return EVBACKEND_EPOLL; |
261 | } |
262 | } |
262 | |
263 | |
263 | void inline_size |
264 | inline_size |
|
|
265 | void |
264 | epoll_destroy (EV_P) |
266 | epoll_destroy (EV_P) |
265 | { |
267 | { |
266 | ev_free (epoll_events); |
268 | ev_free (epoll_events); |
267 | array_free (epoll_eperm, EMPTY); |
269 | array_free (epoll_eperm, EMPTY); |
268 | } |
270 | } |
269 | |
271 | |
270 | void inline_size |
272 | inline_size |
|
|
273 | void |
271 | epoll_fork (EV_P) |
274 | epoll_fork (EV_P) |
272 | { |
275 | { |
273 | close (backend_fd); |
276 | close (backend_fd); |
274 | |
277 | |
275 | while ((backend_fd = epoll_create (256)) < 0) |
278 | while ((backend_fd = epoll_create (256)) < 0) |