X-Git-Url: https://git.llucax.com/software/libev.git/blobdiff_plain/a29fb691be0c199fb643de22a7969a410c3b1e31..096e6ef16f52ddf1b6abcba43a9bbe29aa653735:/ev.c?ds=inline diff --git a/ev.c b/ev.c index 67d0368..7e5923f 100644 --- a/ev.c +++ b/ev.c @@ -12,9 +12,9 @@ # define HAVE_MONOTONIC 1 #endif -#define HAVE_EPOLL 1 #define HAVE_REALTIME 1 -#define HAVE_SELECT 0 +#define HAVE_EPOLL 1 +#define HAVE_SELECT 1 #define MIN_TIMEJUMP 1. /* minimum timejump that gets detected (if monotonic clock available) */ #define MAX_BLOCKTIME 60. @@ -36,7 +36,7 @@ int ev_method; static int have_monotonic; /* runtime */ static ev_tstamp method_fudge; /* stupid epoll-returns-early bug */ -static void (*method_reify)(void); +static void (*method_modify)(int fd, int oev, int nev); static void (*method_poll)(ev_tstamp timeout); ev_tstamp @@ -236,10 +236,37 @@ void ev_postfork_parent (void) void ev_postfork_child (void) { #if HAVE_EPOLL - epoll_postfork_child (); + if (ev_method == EVMETHOD_EPOLL) + epoll_postfork_child (); #endif } +static void +fd_reify (void) +{ + int i; + + for (i = 0; i < fdchangecnt; ++i) + { + int fd = fdchanges [i]; + ANFD *anfd = anfds + fd; + struct ev_io *w; + + int wev = 0; + + for (w = anfd->head; w; w = w->next) + wev |= w->events; + + if (anfd->wev != wev) + { + method_modify (fd, anfd->wev, wev); + anfd->wev = wev; + } + } + + fdchangecnt = 0; +} + static void call_pending () { @@ -338,7 +365,7 @@ void ev_loop (int flags) do { /* update fd-related kernel structures */ - method_reify (); fdchangecnt = 0; + fd_reify (); /* calculate blocking time */ if (flags & EVLOOP_NONBLOCK)