--- libev/ev_epoll.c 2011/12/18 17:47:23 1.66 +++ libev/ev_epoll.c 2017/06/21 14:42:30 1.72 @@ -179,7 +179,7 @@ if (expect_false ((uint32_t)anfds [fd].egen != (uint32_t)(ev->data.u64 >> 32))) { /* recreate kernel state */ - postfork = 1; + postfork |= 2; continue; } @@ -203,7 +203,7 @@ /* which is fortunately easy to do for us. */ if (epoll_ctl (backend_fd, want ? EPOLL_CTL_MOD : EPOLL_CTL_DEL, fd, ev)) { - postfork = 1; /* an error occurred, recreate kernel state */ + postfork |= 2; /* an error occurred, recreate kernel state */ continue; } } @@ -228,17 +228,21 @@ if (anfds [fd].emask & EV_EMASK_EPERM && events) fd_event (EV_A_ fd, events); else - epoll_eperms [i] = epoll_eperms [--epoll_epermcnt]; + { + epoll_eperms [i] = epoll_eperms [--epoll_epermcnt]; + anfds [fd].emask = 0; + } } } -int inline_size +inline_size +int epoll_init (EV_P_ int flags) { -#ifdef EPOLL_CLOEXEC +#if defined EPOLL_CLOEXEC && !defined __ANDROID__ backend_fd = epoll_create1 (EPOLL_CLOEXEC); - if (backend_fd < 0) + if (backend_fd < 0 && (errno == EINVAL || errno == ENOSYS)) #endif backend_fd = epoll_create (256); @@ -257,14 +261,16 @@ return EVBACKEND_EPOLL; } -void inline_size +inline_size +void epoll_destroy (EV_P) { ev_free (epoll_events); array_free (epoll_eperm, EMPTY); } -void inline_size +inline_size +void epoll_fork (EV_P) { close (backend_fd);