… | |
… | |
197 | event (events [i], type); |
197 | event (events [i], type); |
198 | } |
198 | } |
199 | |
199 | |
200 | /* called on EBADF to verify fds */ |
200 | /* called on EBADF to verify fds */ |
201 | static void |
201 | static void |
202 | fd_recheck () |
202 | fd_recheck (void) |
203 | { |
203 | { |
204 | int fd; |
204 | int fd; |
205 | |
205 | |
206 | for (fd = 0; fd < anfdmax; ++fd) |
206 | for (fd = 0; fd < anfdmax; ++fd) |
207 | if (anfds [fd].wev) |
207 | if (anfds [fd].wev) |
208 | if (fcntl (fd, F_GETFD) == -1 && errno == EBADF) |
208 | if (fcntl (fd, F_GETFD) == -1 && errno == EBADF) |
209 | while (anfds [fd].head) |
209 | while (anfds [fd].head) |
|
|
210 | { |
|
|
211 | event ((W)anfds [fd].head, EV_ERROR); |
210 | evio_stop (anfds [fd].head); |
212 | evio_stop (anfds [fd].head); |
|
|
213 | } |
211 | } |
214 | } |
212 | |
215 | |
213 | /*****************************************************************************/ |
216 | /*****************************************************************************/ |
214 | |
217 | |
215 | static struct ev_timer **timers; |
218 | static struct ev_timer **timers; |
… | |
… | |
371 | # include "ev_epoll.c" |
374 | # include "ev_epoll.c" |
372 | #endif |
375 | #endif |
373 | #if HAVE_SELECT |
376 | #if HAVE_SELECT |
374 | # include "ev_select.c" |
377 | # include "ev_select.c" |
375 | #endif |
378 | #endif |
|
|
379 | |
|
|
380 | int |
|
|
381 | ev_version_major (void) |
|
|
382 | { |
|
|
383 | return EV_VERSION_MAJOR; |
|
|
384 | } |
|
|
385 | |
|
|
386 | int |
|
|
387 | ev_version_minor (void) |
|
|
388 | { |
|
|
389 | return EV_VERSION_MINOR; |
|
|
390 | } |
376 | |
391 | |
377 | int ev_init (int flags) |
392 | int ev_init (int flags) |
378 | { |
393 | { |
379 | if (!ev_method) |
394 | if (!ev_method) |
380 | { |
395 | { |
… | |
… | |
414 | return ev_method; |
429 | return ev_method; |
415 | } |
430 | } |
416 | |
431 | |
417 | /*****************************************************************************/ |
432 | /*****************************************************************************/ |
418 | |
433 | |
|
|
434 | void |
419 | void ev_prefork (void) |
435 | ev_prefork (void) |
420 | { |
436 | { |
421 | /* nop */ |
437 | /* nop */ |
422 | } |
438 | } |
423 | |
439 | |
|
|
440 | void |
424 | void ev_postfork_parent (void) |
441 | ev_postfork_parent (void) |
425 | { |
442 | { |
426 | /* nop */ |
443 | /* nop */ |
427 | } |
444 | } |
428 | |
445 | |
|
|
446 | void |
429 | void ev_postfork_child (void) |
447 | ev_postfork_child (void) |
430 | { |
448 | { |
431 | #if HAVE_EPOLL |
449 | #if HAVE_EPOLL |
432 | if (ev_method == EVMETHOD_EPOLL) |
450 | if (ev_method == EVMETHOD_EPOLL) |
433 | epoll_postfork_child (); |
451 | epoll_postfork_child (); |
434 | #endif |
452 | #endif |
… | |
… | |
467 | |
485 | |
468 | fdchangecnt = 0; |
486 | fdchangecnt = 0; |
469 | } |
487 | } |
470 | |
488 | |
471 | static void |
489 | static void |
472 | call_pending () |
490 | call_pending (void) |
473 | { |
491 | { |
474 | while (pendingcnt) |
492 | while (pendingcnt) |
475 | { |
493 | { |
476 | ANPENDING *p = pendings + --pendingcnt; |
494 | ANPENDING *p = pendings + --pendingcnt; |
477 | |
495 | |
… | |
… | |
482 | } |
500 | } |
483 | } |
501 | } |
484 | } |
502 | } |
485 | |
503 | |
486 | static void |
504 | static void |
487 | timers_reify () |
505 | timers_reify (void) |
488 | { |
506 | { |
489 | while (timercnt && timers [0]->at <= now) |
507 | while (timercnt && timers [0]->at <= now) |
490 | { |
508 | { |
491 | struct ev_timer *w = timers [0]; |
509 | struct ev_timer *w = timers [0]; |
492 | |
510 | |
… | |
… | |
503 | evtimer_stop (w); /* nonrepeating: stop timer */ |
521 | evtimer_stop (w); /* nonrepeating: stop timer */ |
504 | } |
522 | } |
505 | } |
523 | } |
506 | |
524 | |
507 | static void |
525 | static void |
508 | periodics_reify () |
526 | periodics_reify (void) |
509 | { |
527 | { |
510 | while (periodiccnt && periodics [0]->at <= ev_now) |
528 | while (periodiccnt && periodics [0]->at <= ev_now) |
511 | { |
529 | { |
512 | struct ev_periodic *w = periodics [0]; |
530 | struct ev_periodic *w = periodics [0]; |
513 | |
531 | |
… | |
… | |
549 | } |
567 | } |
550 | } |
568 | } |
551 | } |
569 | } |
552 | |
570 | |
553 | static void |
571 | static void |
554 | time_update () |
572 | time_update (void) |
555 | { |
573 | { |
556 | int i; |
574 | int i; |
557 | |
575 | |
558 | ev_now = ev_time (); |
576 | ev_now = ev_time (); |
559 | |
577 | |