… | |
… | |
39 | #include <assert.h> |
39 | #include <assert.h> |
40 | #include <errno.h> |
40 | #include <errno.h> |
41 | #include <sys/time.h> |
41 | #include <sys/time.h> |
42 | #include <time.h> |
42 | #include <time.h> |
43 | |
43 | |
44 | #define HAVE_EPOLL 1 |
|
|
45 | |
|
|
46 | #ifndef HAVE_MONOTONIC |
44 | #ifndef HAVE_MONOTONIC |
47 | # ifdef CLOCK_MONOTONIC |
45 | # ifdef CLOCK_MONOTONIC |
48 | # define HAVE_MONOTONIC 1 |
46 | # define HAVE_MONOTONIC 1 |
49 | # endif |
47 | # endif |
50 | #endif |
48 | #endif |
… | |
… | |
188 | |
186 | |
189 | for (i = 0; i < eventcnt; ++i) |
187 | for (i = 0; i < eventcnt; ++i) |
190 | event (events [i], type); |
188 | event (events [i], type); |
191 | } |
189 | } |
192 | |
190 | |
|
|
191 | /* called on EBADF to verify fds */ |
|
|
192 | static void |
|
|
193 | fd_recheck () |
|
|
194 | { |
|
|
195 | int fd; |
|
|
196 | |
|
|
197 | for (fd = 0; fd < anfdmax; ++fd) |
|
|
198 | if (anfds [fd].wev) |
|
|
199 | if (fcntl (fd, F_GETFD) == -1 && errno == EBADF) |
|
|
200 | while (anfds [fd].head) |
|
|
201 | evio_stop (anfds [fd].head); |
|
|
202 | } |
|
|
203 | |
193 | /*****************************************************************************/ |
204 | /*****************************************************************************/ |
194 | |
205 | |
195 | static struct ev_timer **timers; |
206 | static struct ev_timer **timers; |
196 | static int timermax, timercnt; |
207 | static int timermax, timercnt; |
197 | |
208 | |
… | |
… | |
416 | } |
427 | } |
417 | |
428 | |
418 | static void |
429 | static void |
419 | call_pending () |
430 | call_pending () |
420 | { |
431 | { |
421 | int i; |
432 | while (pendingcnt) |
422 | |
|
|
423 | for (i = 0; i < pendingcnt; ++i) |
|
|
424 | { |
433 | { |
425 | ANPENDING *p = pendings + i; |
434 | ANPENDING *p = pendings + --pendingcnt; |
426 | |
435 | |
427 | if (p->w) |
436 | if (p->w) |
428 | { |
437 | { |
429 | p->w->pending = 0; |
438 | p->w->pending = 0; |
430 | p->w->cb (p->w, p->events); |
439 | p->w->cb (p->w, p->events); |
431 | } |
440 | } |
432 | } |
441 | } |
433 | |
|
|
434 | pendingcnt = 0; |
|
|
435 | } |
442 | } |
436 | |
443 | |
437 | static void |
444 | static void |
438 | timers_reify () |
445 | timers_reify () |
439 | { |
446 | { |