… | |
… | |
12 | # define HAVE_MONOTONIC 1 |
12 | # define HAVE_MONOTONIC 1 |
13 | #endif |
13 | #endif |
14 | |
14 | |
15 | #define HAVE_EPOLL 1 |
15 | #define HAVE_EPOLL 1 |
16 | #define HAVE_REALTIME 1 |
16 | #define HAVE_REALTIME 1 |
17 | #define HAVE_SELECT 0 |
17 | #define HAVE_SELECT 1 |
18 | |
18 | |
19 | #define MIN_TIMEJUMP 1. /* minimum timejump that gets detected (if monotonic clock available) */ |
19 | #define MIN_TIMEJUMP 1. /* minimum timejump that gets detected (if monotonic clock available) */ |
20 | #define MAX_BLOCKTIME 60. |
20 | #define MAX_BLOCKTIME 60. |
21 | |
21 | |
22 | #include "ev.h" |
22 | #include "ev.h" |
… | |
… | |
34 | int ev_method; |
34 | int ev_method; |
35 | |
35 | |
36 | static int have_monotonic; /* runtime */ |
36 | static int have_monotonic; /* runtime */ |
37 | |
37 | |
38 | static ev_tstamp method_fudge; /* stupid epoll-returns-early bug */ |
38 | static ev_tstamp method_fudge; /* stupid epoll-returns-early bug */ |
39 | static void (*method_reify)(void); |
39 | static void (*method_modify)(int fd, int oev, int nev); |
40 | static void (*method_poll)(ev_tstamp timeout); |
40 | static void (*method_poll)(ev_tstamp timeout); |
41 | |
41 | |
42 | ev_tstamp |
42 | ev_tstamp |
43 | ev_time (void) |
43 | ev_time (void) |
44 | { |
44 | { |
… | |
… | |
234 | } |
234 | } |
235 | |
235 | |
236 | void ev_postfork_child (void) |
236 | void ev_postfork_child (void) |
237 | { |
237 | { |
238 | #if HAVE_EPOLL |
238 | #if HAVE_EPOLL |
|
|
239 | if (ev_method == EVMETHOD_EPOLL) |
239 | epoll_postfork_child (); |
240 | epoll_postfork_child (); |
240 | #endif |
241 | #endif |
|
|
242 | } |
|
|
243 | |
|
|
244 | static void |
|
|
245 | fd_reify (void) |
|
|
246 | { |
|
|
247 | int i; |
|
|
248 | |
|
|
249 | for (i = 0; i < fdchangecnt; ++i) |
|
|
250 | { |
|
|
251 | int fd = fdchanges [i]; |
|
|
252 | ANFD *anfd = anfds + fd; |
|
|
253 | struct ev_io *w; |
|
|
254 | |
|
|
255 | int wev = 0; |
|
|
256 | |
|
|
257 | for (w = anfd->head; w; w = w->next) |
|
|
258 | wev |= w->events; |
|
|
259 | |
|
|
260 | if (anfd->wev != wev) |
|
|
261 | { |
|
|
262 | method_modify (fd, anfd->wev, wev); |
|
|
263 | anfd->wev = wev; |
|
|
264 | } |
|
|
265 | } |
|
|
266 | |
|
|
267 | fdchangecnt = 0; |
241 | } |
268 | } |
242 | |
269 | |
243 | static void |
270 | static void |
244 | call_pending () |
271 | call_pending () |
245 | { |
272 | { |
… | |
… | |
336 | ev_loop_done = flags & EVLOOP_ONESHOT; |
363 | ev_loop_done = flags & EVLOOP_ONESHOT; |
337 | |
364 | |
338 | do |
365 | do |
339 | { |
366 | { |
340 | /* update fd-related kernel structures */ |
367 | /* update fd-related kernel structures */ |
341 | method_reify (); fdchangecnt = 0; |
368 | fd_reify (); |
342 | |
369 | |
343 | /* calculate blocking time */ |
370 | /* calculate blocking time */ |
344 | if (flags & EVLOOP_NONBLOCK) |
371 | if (flags & EVLOOP_NONBLOCK) |
345 | block = 0.; |
372 | block = 0.; |
346 | else |
373 | else |