… | |
… | |
233 | anfds [fd].emask = 0; |
233 | anfds [fd].emask = 0; |
234 | } |
234 | } |
235 | } |
235 | } |
236 | } |
236 | } |
237 | |
237 | |
|
|
238 | static int |
|
|
239 | ev_epoll_create (void) |
|
|
240 | { |
|
|
241 | int fd; |
|
|
242 | |
|
|
243 | #if defined EPOLL_CLOEXEC && !defined __ANDROID__ |
|
|
244 | fd = epoll_create1 (EPOLL_CLOEXEC); |
|
|
245 | |
|
|
246 | if (fd < 0 && (errno == EINVAL || errno == ENOSYS)) |
|
|
247 | #endif |
|
|
248 | { |
|
|
249 | fd = epoll_create (256); |
|
|
250 | |
|
|
251 | if (fd >= 0) |
|
|
252 | fcntl (fd, F_SETFD, FD_CLOEXEC); |
|
|
253 | } |
|
|
254 | |
|
|
255 | return fd; |
|
|
256 | } |
|
|
257 | |
238 | inline_size |
258 | inline_size |
239 | int |
259 | int |
240 | epoll_init (EV_P_ int flags) |
260 | epoll_init (EV_P_ int flags) |
241 | { |
261 | { |
242 | #if defined EPOLL_CLOEXEC && !defined __ANDROID__ |
|
|
243 | backend_fd = epoll_create1 (EPOLL_CLOEXEC); |
|
|
244 | |
|
|
245 | if (backend_fd < 0 && (errno == EINVAL || errno == ENOSYS)) |
|
|
246 | #endif |
|
|
247 | backend_fd = epoll_create (256); |
262 | if ((backend_fd = ev_epoll_create ()) < 0) |
248 | |
|
|
249 | if (backend_fd < 0) |
|
|
250 | return 0; |
263 | return 0; |
251 | |
|
|
252 | fcntl (backend_fd, F_SETFD, FD_CLOEXEC); |
|
|
253 | |
264 | |
254 | backend_mintime = 1e-3; /* epoll does sometimes return early, this is just to avoid the worst */ |
265 | backend_mintime = 1e-3; /* epoll does sometimes return early, this is just to avoid the worst */ |
255 | backend_modify = epoll_modify; |
266 | backend_modify = epoll_modify; |
256 | backend_poll = epoll_poll; |
267 | backend_poll = epoll_poll; |
257 | |
268 | |
… | |
… | |
273 | void |
284 | void |
274 | epoll_fork (EV_P) |
285 | epoll_fork (EV_P) |
275 | { |
286 | { |
276 | close (backend_fd); |
287 | close (backend_fd); |
277 | |
288 | |
278 | while ((backend_fd = epoll_create (256)) < 0) |
289 | while ((backend_fd = ev_epoll_create ()) < 0) |
279 | ev_syserr ("(libev) epoll_create"); |
290 | ev_syserr ("(libev) epoll_create"); |
280 | |
291 | |
281 | fcntl (backend_fd, F_SETFD, FD_CLOEXEC); |
|
|
282 | |
|
|
283 | fd_rearm_all (EV_A); |
292 | fd_rearm_all (EV_A); |
284 | } |
293 | } |
285 | |
294 | |