… | |
… | |
117 | # define EV_USE_EPOLL 0 |
117 | # define EV_USE_EPOLL 0 |
118 | # endif |
118 | # endif |
119 | |
119 | |
120 | # if HAVE_LINUX_AIO_ABI_H |
120 | # if HAVE_LINUX_AIO_ABI_H |
121 | # ifndef EV_USE_LINUXAIO |
121 | # ifndef EV_USE_LINUXAIO |
122 | # define EV_USE_LINUXAIO EV_FEATURE_BACKENDS |
122 | # define EV_USE_LINUXAIO 0 /* was: EV_FEATURE_BACKENDS, always off by default */ |
123 | # endif |
123 | # endif |
124 | # else |
124 | # else |
125 | # undef EV_USE_LINUXAIO |
125 | # undef EV_USE_LINUXAIO |
126 | # define EV_USE_LINUXAIO 0 |
126 | # define EV_USE_LINUXAIO 0 |
127 | # endif |
127 | # endif |
… | |
… | |
178 | # else |
178 | # else |
179 | # undef EV_USE_EVENTFD |
179 | # undef EV_USE_EVENTFD |
180 | # define EV_USE_EVENTFD 0 |
180 | # define EV_USE_EVENTFD 0 |
181 | # endif |
181 | # endif |
182 | |
182 | |
|
|
183 | # if HAVE_SYS_TIMERFD_H |
|
|
184 | # ifndef EV_USE_TIMERFD |
|
|
185 | # define EV_USE_TIMERFD EV_FEATURE_OS |
|
|
186 | # endif |
|
|
187 | # else |
|
|
188 | # undef EV_USE_TIMERFD |
|
|
189 | # define EV_USE_TIMERFD 0 |
|
|
190 | # endif |
|
|
191 | |
183 | #endif |
192 | #endif |
184 | |
193 | |
185 | /* OS X, in its infinite idiocy, actually HARDCODES |
194 | /* OS X, in its infinite idiocy, actually HARDCODES |
186 | * a limit of 1024 into their select. Where people have brains, |
195 | * a limit of 1024 into their select. Where people have brains, |
187 | * OS X engineers apparently have a vacuum. Or maybe they were |
196 | * OS X engineers apparently have a vacuum. Or maybe they were |
… | |
… | |
335 | # define EV_USE_PORT 0 |
344 | # define EV_USE_PORT 0 |
336 | #endif |
345 | #endif |
337 | |
346 | |
338 | #ifndef EV_USE_LINUXAIO |
347 | #ifndef EV_USE_LINUXAIO |
339 | # if __linux /* libev currently assumes linux/aio_abi.h is always available on linux */ |
348 | # if __linux /* libev currently assumes linux/aio_abi.h is always available on linux */ |
340 | # define EV_USE_LINUXAIO 1 |
349 | # define EV_USE_LINUXAIO 0 /* was: 1, always off by default */ |
341 | # else |
350 | # else |
342 | # define EV_USE_LINUXAIO 0 |
351 | # define EV_USE_LINUXAIO 0 |
343 | # endif |
352 | # endif |
344 | #endif |
353 | #endif |
345 | |
354 | |
… | |
… | |
378 | #ifndef EV_USE_SIGNALFD |
387 | #ifndef EV_USE_SIGNALFD |
379 | # if __linux && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 7)) |
388 | # if __linux && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 7)) |
380 | # define EV_USE_SIGNALFD EV_FEATURE_OS |
389 | # define EV_USE_SIGNALFD EV_FEATURE_OS |
381 | # else |
390 | # else |
382 | # define EV_USE_SIGNALFD 0 |
391 | # define EV_USE_SIGNALFD 0 |
|
|
392 | # endif |
|
|
393 | #endif |
|
|
394 | |
|
|
395 | #ifndef EV_USE_TIMERFD |
|
|
396 | # if __linux && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 8)) |
|
|
397 | # define EV_USE_TIMERFD EV_FEATURE_OS |
|
|
398 | # else |
|
|
399 | # define EV_USE_TIMERFD 0 |
383 | # endif |
400 | # endif |
384 | #endif |
401 | #endif |
385 | |
402 | |
386 | #if 0 /* debugging */ |
403 | #if 0 /* debugging */ |
387 | # define EV_VERIFY 3 |
404 | # define EV_VERIFY 3 |
… | |
… | |
498 | # define EV_USE_INOTIFY 0 |
515 | # define EV_USE_INOTIFY 0 |
499 | # endif |
516 | # endif |
500 | #endif |
517 | #endif |
501 | |
518 | |
502 | #if EV_USE_EVENTFD |
519 | #if EV_USE_EVENTFD |
503 | /* our minimum requirement is glibc 2.7 which has the stub, but not the header */ |
520 | /* our minimum requirement is glibc 2.7 which has the stub, but not the full header */ |
504 | # include <stdint.h> |
521 | # include <stdint.h> |
505 | # ifndef EFD_NONBLOCK |
522 | # ifndef EFD_NONBLOCK |
506 | # define EFD_NONBLOCK O_NONBLOCK |
523 | # define EFD_NONBLOCK O_NONBLOCK |
507 | # endif |
524 | # endif |
508 | # ifndef EFD_CLOEXEC |
525 | # ifndef EFD_CLOEXEC |
… | |
… | |
514 | # endif |
531 | # endif |
515 | EV_CPP(extern "C") int (eventfd) (unsigned int initval, int flags); |
532 | EV_CPP(extern "C") int (eventfd) (unsigned int initval, int flags); |
516 | #endif |
533 | #endif |
517 | |
534 | |
518 | #if EV_USE_SIGNALFD |
535 | #if EV_USE_SIGNALFD |
519 | /* our minimum requirement is glibc 2.7 which has the stub, but not the header */ |
536 | /* our minimum requirement is glibc 2.7 which has the stub, but not the full header */ |
520 | # include <stdint.h> |
537 | # include <stdint.h> |
521 | # ifndef SFD_NONBLOCK |
538 | # ifndef SFD_NONBLOCK |
522 | # define SFD_NONBLOCK O_NONBLOCK |
539 | # define SFD_NONBLOCK O_NONBLOCK |
523 | # endif |
540 | # endif |
524 | # ifndef SFD_CLOEXEC |
541 | # ifndef SFD_CLOEXEC |
… | |
… | |
526 | # define SFD_CLOEXEC O_CLOEXEC |
543 | # define SFD_CLOEXEC O_CLOEXEC |
527 | # else |
544 | # else |
528 | # define SFD_CLOEXEC 02000000 |
545 | # define SFD_CLOEXEC 02000000 |
529 | # endif |
546 | # endif |
530 | # endif |
547 | # endif |
531 | EV_CPP (extern "C") int signalfd (int fd, const sigset_t *mask, int flags); |
548 | EV_CPP (extern "C") int (signalfd) (int fd, const sigset_t *mask, int flags); |
532 | |
549 | |
533 | struct signalfd_siginfo |
550 | struct signalfd_siginfo |
534 | { |
551 | { |
535 | uint32_t ssi_signo; |
552 | uint32_t ssi_signo; |
536 | char pad[128 - sizeof (uint32_t)]; |
553 | char pad[128 - sizeof (uint32_t)]; |
537 | }; |
554 | }; |
|
|
555 | #endif |
|
|
556 | |
|
|
557 | /* for timerfd, libev core requires TFD_TIMER_CANCEL_ON_SET &c */ |
|
|
558 | #if EV_USE_TIMERFD |
|
|
559 | # include <sys/timerfd.h> |
|
|
560 | /* timerfd is only used for periodics */ |
|
|
561 | # if !(defined (TFD_TIMER_CANCEL_ON_SET) && defined (TFD_CLOEXEC) && defined (TFD_NONBLOCK)) || !EV_PERIODIC_ENABLE |
|
|
562 | # undef EV_USE_TIMERFD |
|
|
563 | # define EV_USE_TIMERFD 0 |
|
|
564 | # endif |
538 | #endif |
565 | #endif |
539 | |
566 | |
540 | /*****************************************************************************/ |
567 | /*****************************************************************************/ |
541 | |
568 | |
542 | #if EV_VERIFY >= 3 |
569 | #if EV_VERIFY >= 3 |
… | |
… | |
1631 | * our syscalls return < 0, not == -1, on error. which is good |
1658 | * our syscalls return < 0, not == -1, on error. which is good |
1632 | * enough for linux aio. |
1659 | * enough for linux aio. |
1633 | * TODO: arm is also common nowadays, maybe even mips and x86 |
1660 | * TODO: arm is also common nowadays, maybe even mips and x86 |
1634 | * TODO: after implementing this, it suddenly looks like overkill, but its hard to remove... |
1661 | * TODO: after implementing this, it suddenly looks like overkill, but its hard to remove... |
1635 | */ |
1662 | */ |
1636 | #if __GNUC__ && __linux && ECB_AMD64 && !defined __OPTIMIZE_SIZE__ |
1663 | #if __GNUC__ && __linux && ECB_AMD64 && !EV_FEATURE_CODE |
1637 | /* the costly errno access probably kills this for size optimisation */ |
1664 | /* the costly errno access probably kills this for size optimisation */ |
1638 | |
1665 | |
1639 | #define ev_syscall(nr,narg,arg1,arg2,arg3,arg4,arg5,arg6) \ |
1666 | #define ev_syscall(nr,narg,arg1,arg2,arg3,arg4,arg5,arg6) \ |
1640 | ({ \ |
1667 | ({ \ |
1641 | long res; \ |
1668 | long res; \ |
… | |
… | |
2235 | inline_size void |
2262 | inline_size void |
2236 | fd_reify (EV_P) |
2263 | fd_reify (EV_P) |
2237 | { |
2264 | { |
2238 | int i; |
2265 | int i; |
2239 | |
2266 | |
|
|
2267 | /* most backends do not modify the fdchanges list in backend_modfiy. |
|
|
2268 | * except io_uring, which has fixed-size buffers which might force us |
|
|
2269 | * to handle events in backend_modify, causing fdchangesd to be amended, |
|
|
2270 | * which could result in an endless loop. |
|
|
2271 | * to avoid this, we do not dynamically handle fds that were added |
|
|
2272 | * during fd_reify. that menas thast for those backends, fdchangecnt |
|
|
2273 | * might be non-zero during poll, which must cause them to not block. |
|
|
2274 | * to not put too much of a burden on other backends, this detail |
|
|
2275 | * needs to be handled in the backend. |
|
|
2276 | */ |
|
|
2277 | int changecnt = fdchangecnt; |
|
|
2278 | |
2240 | #if EV_SELECT_IS_WINSOCKET || EV_USE_IOCP |
2279 | #if EV_SELECT_IS_WINSOCKET || EV_USE_IOCP |
2241 | for (i = 0; i < fdchangecnt; ++i) |
2280 | for (i = 0; i < changecnt; ++i) |
2242 | { |
2281 | { |
2243 | int fd = fdchanges [i]; |
2282 | int fd = fdchanges [i]; |
2244 | ANFD *anfd = anfds + fd; |
2283 | ANFD *anfd = anfds + fd; |
2245 | |
2284 | |
2246 | if (anfd->reify & EV__IOFDSET && anfd->head) |
2285 | if (anfd->reify & EV__IOFDSET && anfd->head) |
… | |
… | |
2260 | } |
2299 | } |
2261 | } |
2300 | } |
2262 | } |
2301 | } |
2263 | #endif |
2302 | #endif |
2264 | |
2303 | |
2265 | for (i = 0; i < fdchangecnt; ++i) |
2304 | for (i = 0; i < changecnt; ++i) |
2266 | { |
2305 | { |
2267 | int fd = fdchanges [i]; |
2306 | int fd = fdchanges [i]; |
2268 | ANFD *anfd = anfds + fd; |
2307 | ANFD *anfd = anfds + fd; |
2269 | ev_io *w; |
2308 | ev_io *w; |
2270 | |
2309 | |
… | |
… | |
2286 | |
2325 | |
2287 | if (o_reify & EV__IOFDSET) |
2326 | if (o_reify & EV__IOFDSET) |
2288 | backend_modify (EV_A_ fd, o_events, anfd->events); |
2327 | backend_modify (EV_A_ fd, o_events, anfd->events); |
2289 | } |
2328 | } |
2290 | |
2329 | |
|
|
2330 | /* normally, fdchangecnt hasn't changed. if it has, then new fds have been added. |
|
|
2331 | * this is a rare case (see beginning comment in this function), so we copy them to the |
|
|
2332 | * front and hope the backend handles this case. |
|
|
2333 | */ |
|
|
2334 | if (ecb_expect_false (fdchangecnt != changecnt)) |
|
|
2335 | memmove (fdchanges, fdchanges + changecnt, (fdchangecnt - changecnt) * sizeof (*fdchanges)); |
|
|
2336 | |
2291 | fdchangecnt = 0; |
2337 | fdchangecnt -= changecnt; |
2292 | } |
2338 | } |
2293 | |
2339 | |
2294 | /* something about the given fd changed */ |
2340 | /* something about the given fd changed */ |
2295 | inline_size |
2341 | inline_size |
2296 | void |
2342 | void |
… | |
… | |
2534 | upheap (heap, i + HEAP0); |
2580 | upheap (heap, i + HEAP0); |
2535 | } |
2581 | } |
2536 | |
2582 | |
2537 | /*****************************************************************************/ |
2583 | /*****************************************************************************/ |
2538 | |
2584 | |
2539 | /* associate signal watchers to a signal signal */ |
2585 | /* associate signal watchers to a signal */ |
2540 | typedef struct |
2586 | typedef struct |
2541 | { |
2587 | { |
2542 | EV_ATOMIC_T pending; |
2588 | EV_ATOMIC_T pending; |
2543 | #if EV_MULTIPLICITY |
2589 | #if EV_MULTIPLICITY |
2544 | EV_P; |
2590 | EV_P; |
… | |
… | |
2848 | |
2894 | |
2849 | #endif |
2895 | #endif |
2850 | |
2896 | |
2851 | /*****************************************************************************/ |
2897 | /*****************************************************************************/ |
2852 | |
2898 | |
|
|
2899 | #if EV_USE_TIMERFD |
|
|
2900 | |
|
|
2901 | static void periodics_reschedule (EV_P); |
|
|
2902 | |
|
|
2903 | static void |
|
|
2904 | timerfdcb (EV_P_ ev_io *iow, int revents) |
|
|
2905 | { |
|
|
2906 | struct itimerspec its = { 0 }; |
|
|
2907 | |
|
|
2908 | /* since we can't easily come zup with a (portable) maximum value of time_t, |
|
|
2909 | * we wake up once per month, which hopefully is rare enough to not |
|
|
2910 | * be a problem. */ |
|
|
2911 | its.it_value.tv_sec = ev_rt_now + 86400 * 30; |
|
|
2912 | timerfd_settime (timerfd, TFD_TIMER_ABSTIME | TFD_TIMER_CANCEL_ON_SET, &its, 0); |
|
|
2913 | |
|
|
2914 | ev_rt_now = ev_time (); |
|
|
2915 | /* periodics_reschedule only needs ev_rt_now */ |
|
|
2916 | /* but maybe in the future we want the full treatment. */ |
|
|
2917 | /* |
|
|
2918 | now_floor = EV_TS_CONST (0.); |
|
|
2919 | time_update (EV_A_ EV_TSTAMP_HUGE); |
|
|
2920 | */ |
|
|
2921 | periodics_reschedule (EV_A); |
|
|
2922 | } |
|
|
2923 | |
|
|
2924 | ecb_noinline ecb_cold |
|
|
2925 | static void |
|
|
2926 | evtimerfd_init (EV_P) |
|
|
2927 | { |
|
|
2928 | if (!ev_is_active (&timerfd_w)) |
|
|
2929 | { |
|
|
2930 | timerfd = timerfd_create (CLOCK_REALTIME, TFD_NONBLOCK | TFD_CLOEXEC); |
|
|
2931 | |
|
|
2932 | if (timerfd >= 0) |
|
|
2933 | { |
|
|
2934 | fd_intern (timerfd); /* just to be sure */ |
|
|
2935 | |
|
|
2936 | ev_io_init (&timerfd_w, timerfdcb, timerfd, EV_READ); |
|
|
2937 | ev_set_priority (&timerfd_w, EV_MINPRI); |
|
|
2938 | ev_io_start (EV_A_ &timerfd_w); |
|
|
2939 | ev_unref (EV_A); /* watcher should not keep loop alive */ |
|
|
2940 | |
|
|
2941 | /* (re-) arm timer */ |
|
|
2942 | timerfdcb (EV_A_ 0, 0); |
|
|
2943 | } |
|
|
2944 | } |
|
|
2945 | } |
|
|
2946 | |
|
|
2947 | #endif |
|
|
2948 | |
|
|
2949 | /*****************************************************************************/ |
|
|
2950 | |
2853 | #if EV_USE_IOCP |
2951 | #if EV_USE_IOCP |
2854 | # include "ev_iocp.c" |
2952 | # include "ev_iocp.c" |
2855 | #endif |
2953 | #endif |
2856 | #if EV_USE_PORT |
2954 | #if EV_USE_PORT |
2857 | # include "ev_port.c" |
2955 | # include "ev_port.c" |
… | |
… | |
2903 | unsigned int |
3001 | unsigned int |
2904 | ev_supported_backends (void) EV_NOEXCEPT |
3002 | ev_supported_backends (void) EV_NOEXCEPT |
2905 | { |
3003 | { |
2906 | unsigned int flags = 0; |
3004 | unsigned int flags = 0; |
2907 | |
3005 | |
2908 | if (EV_USE_PORT ) flags |= EVBACKEND_PORT; |
3006 | if (EV_USE_PORT ) flags |= EVBACKEND_PORT; |
2909 | if (EV_USE_KQUEUE ) flags |= EVBACKEND_KQUEUE; |
3007 | if (EV_USE_KQUEUE ) flags |= EVBACKEND_KQUEUE; |
2910 | if (EV_USE_EPOLL ) flags |= EVBACKEND_EPOLL; |
3008 | if (EV_USE_EPOLL ) flags |= EVBACKEND_EPOLL; |
2911 | if (EV_USE_LINUXAIO) flags |= EVBACKEND_LINUXAIO; |
3009 | if (EV_USE_LINUXAIO ) flags |= EVBACKEND_LINUXAIO; |
2912 | if (EV_USE_IOURING ) flags |= EVBACKEND_IOURING; |
3010 | if (EV_USE_IOURING && ev_linux_version () >= 0x050601) flags |= EVBACKEND_IOURING; /* 5.6.1+ */ |
2913 | if (EV_USE_POLL ) flags |= EVBACKEND_POLL; |
3011 | if (EV_USE_POLL ) flags |= EVBACKEND_POLL; |
2914 | if (EV_USE_SELECT ) flags |= EVBACKEND_SELECT; |
3012 | if (EV_USE_SELECT ) flags |= EVBACKEND_SELECT; |
2915 | |
3013 | |
2916 | return flags; |
3014 | return flags; |
2917 | } |
3015 | } |
2918 | |
3016 | |
2919 | ecb_cold |
3017 | ecb_cold |
2920 | unsigned int |
3018 | unsigned int |
… | |
… | |
2950 | |
3048 | |
2951 | ecb_cold |
3049 | ecb_cold |
2952 | unsigned int |
3050 | unsigned int |
2953 | ev_embeddable_backends (void) EV_NOEXCEPT |
3051 | ev_embeddable_backends (void) EV_NOEXCEPT |
2954 | { |
3052 | { |
2955 | int flags = EVBACKEND_EPOLL | EVBACKEND_KQUEUE | EVBACKEND_PORT; |
3053 | int flags = EVBACKEND_EPOLL | EVBACKEND_KQUEUE | EVBACKEND_PORT | EVBACKEND_IOURING; |
2956 | |
3054 | |
2957 | /* epoll embeddability broken on all linux versions up to at least 2.6.23 */ |
3055 | /* epoll embeddability broken on all linux versions up to at least 2.6.23 */ |
2958 | if (ev_linux_version () < 0x020620) /* disable it on linux < 2.6.32 */ |
3056 | if (ev_linux_version () < 0x020620) /* disable it on linux < 2.6.32 */ |
2959 | flags &= ~EVBACKEND_EPOLL; |
3057 | flags &= ~EVBACKEND_EPOLL; |
2960 | |
3058 | |
2961 | /* EVBACKEND_LINUXAIO is theoretically embeddable, but suffers from a performance overhead */ |
3059 | /* EVBACKEND_LINUXAIO is theoretically embeddable, but suffers from a performance overhead */ |
2962 | |
|
|
2963 | /* EVBACKEND_IOURING is practically embeddable, but the current implementation is not |
|
|
2964 | * because our backend_fd is the epoll fd we need as fallback. |
|
|
2965 | * if the kernel ever is fixed, this might change... |
|
|
2966 | */ |
|
|
2967 | |
3060 | |
2968 | return flags; |
3061 | return flags; |
2969 | } |
3062 | } |
2970 | |
3063 | |
2971 | unsigned int |
3064 | unsigned int |
… | |
… | |
3089 | fs_fd = flags & EVFLAG_NOINOTIFY ? -1 : -2; |
3182 | fs_fd = flags & EVFLAG_NOINOTIFY ? -1 : -2; |
3090 | #endif |
3183 | #endif |
3091 | #if EV_USE_SIGNALFD |
3184 | #if EV_USE_SIGNALFD |
3092 | sigfd = flags & EVFLAG_SIGNALFD ? -2 : -1; |
3185 | sigfd = flags & EVFLAG_SIGNALFD ? -2 : -1; |
3093 | #endif |
3186 | #endif |
|
|
3187 | #if EV_USE_TIMERFD |
|
|
3188 | timerfd = flags & EVFLAG_NOTIMERFD ? -1 : -2; |
|
|
3189 | #endif |
3094 | |
3190 | |
3095 | if (!(flags & EVBACKEND_MASK)) |
3191 | if (!(flags & EVBACKEND_MASK)) |
3096 | flags |= ev_recommended_backends (); |
3192 | flags |= ev_recommended_backends (); |
3097 | |
3193 | |
3098 | #if EV_USE_IOCP |
3194 | #if EV_USE_IOCP |
… | |
… | |
3169 | } |
3265 | } |
3170 | |
3266 | |
3171 | #if EV_USE_SIGNALFD |
3267 | #if EV_USE_SIGNALFD |
3172 | if (ev_is_active (&sigfd_w)) |
3268 | if (ev_is_active (&sigfd_w)) |
3173 | close (sigfd); |
3269 | close (sigfd); |
|
|
3270 | #endif |
|
|
3271 | |
|
|
3272 | #if EV_USE_TIMERFD |
|
|
3273 | if (ev_is_active (&timerfd_w)) |
|
|
3274 | close (timerfd); |
3174 | #endif |
3275 | #endif |
3175 | |
3276 | |
3176 | #if EV_USE_INOTIFY |
3277 | #if EV_USE_INOTIFY |
3177 | if (fs_fd >= 0) |
3278 | if (fs_fd >= 0) |
3178 | close (fs_fd); |
3279 | close (fs_fd); |
… | |
… | |
3271 | #endif |
3372 | #endif |
3272 | #if EV_USE_INOTIFY |
3373 | #if EV_USE_INOTIFY |
3273 | infy_fork (EV_A); |
3374 | infy_fork (EV_A); |
3274 | #endif |
3375 | #endif |
3275 | |
3376 | |
|
|
3377 | if (postfork != 2) |
|
|
3378 | { |
|
|
3379 | #if EV_USE_SIGNALFD |
|
|
3380 | /* surprisingly, nothing needs to be done for signalfd, accoridng to docs, it does the right thing on fork */ |
|
|
3381 | #endif |
|
|
3382 | |
|
|
3383 | #if EV_USE_TIMERFD |
|
|
3384 | if (ev_is_active (&timerfd_w)) |
|
|
3385 | { |
|
|
3386 | ev_ref (EV_A); |
|
|
3387 | ev_io_stop (EV_A_ &timerfd_w); |
|
|
3388 | |
|
|
3389 | close (timerfd); |
|
|
3390 | timerfd = -2; |
|
|
3391 | |
|
|
3392 | evtimerfd_init (EV_A); |
|
|
3393 | /* reschedule periodics, in case we missed something */ |
|
|
3394 | ev_feed_event (EV_A_ &timerfd_w, EV_CUSTOM); |
|
|
3395 | } |
|
|
3396 | #endif |
|
|
3397 | |
3276 | #if EV_SIGNAL_ENABLE || EV_ASYNC_ENABLE |
3398 | #if EV_SIGNAL_ENABLE || EV_ASYNC_ENABLE |
3277 | if (ev_is_active (&pipe_w) && postfork != 2) |
3399 | if (ev_is_active (&pipe_w)) |
3278 | { |
3400 | { |
3279 | /* pipe_write_wanted must be false now, so modifying fd vars should be safe */ |
3401 | /* pipe_write_wanted must be false now, so modifying fd vars should be safe */ |
3280 | |
3402 | |
3281 | ev_ref (EV_A); |
3403 | ev_ref (EV_A); |
3282 | ev_io_stop (EV_A_ &pipe_w); |
3404 | ev_io_stop (EV_A_ &pipe_w); |
3283 | |
3405 | |
3284 | if (evpipe [0] >= 0) |
3406 | if (evpipe [0] >= 0) |
3285 | EV_WIN32_CLOSE_FD (evpipe [0]); |
3407 | EV_WIN32_CLOSE_FD (evpipe [0]); |
3286 | |
3408 | |
3287 | evpipe_init (EV_A); |
3409 | evpipe_init (EV_A); |
3288 | /* iterate over everything, in case we missed something before */ |
3410 | /* iterate over everything, in case we missed something before */ |
3289 | ev_feed_event (EV_A_ &pipe_w, EV_CUSTOM); |
3411 | ev_feed_event (EV_A_ &pipe_w, EV_CUSTOM); |
|
|
3412 | } |
|
|
3413 | #endif |
3290 | } |
3414 | } |
3291 | #endif |
|
|
3292 | |
3415 | |
3293 | postfork = 0; |
3416 | postfork = 0; |
3294 | } |
3417 | } |
3295 | |
3418 | |
3296 | #if EV_MULTIPLICITY |
3419 | #if EV_MULTIPLICITY |
… | |
… | |
4211 | void |
4334 | void |
4212 | ev_periodic_start (EV_P_ ev_periodic *w) EV_NOEXCEPT |
4335 | ev_periodic_start (EV_P_ ev_periodic *w) EV_NOEXCEPT |
4213 | { |
4336 | { |
4214 | if (ecb_expect_false (ev_is_active (w))) |
4337 | if (ecb_expect_false (ev_is_active (w))) |
4215 | return; |
4338 | return; |
|
|
4339 | |
|
|
4340 | #if EV_USE_TIMERFD |
|
|
4341 | if (timerfd == -2) |
|
|
4342 | evtimerfd_init (EV_A); |
|
|
4343 | #endif |
4216 | |
4344 | |
4217 | if (w->reschedule_cb) |
4345 | if (w->reschedule_cb) |
4218 | ev_at (w) = w->reschedule_cb (w, ev_rt_now); |
4346 | ev_at (w) = w->reschedule_cb (w, ev_rt_now); |
4219 | else if (w->interval) |
4347 | else if (w->interval) |
4220 | { |
4348 | { |
… | |
… | |
4962 | ev_run (EV_A_ EVRUN_NOWAIT); |
5090 | ev_run (EV_A_ EVRUN_NOWAIT); |
4963 | } |
5091 | } |
4964 | } |
5092 | } |
4965 | } |
5093 | } |
4966 | |
5094 | |
|
|
5095 | #if EV_FORK_ENABLE |
4967 | static void |
5096 | static void |
4968 | embed_fork_cb (EV_P_ ev_fork *fork_w, int revents) |
5097 | embed_fork_cb (EV_P_ ev_fork *fork_w, int revents) |
4969 | { |
5098 | { |
4970 | ev_embed *w = (ev_embed *)(((char *)fork_w) - offsetof (ev_embed, fork)); |
5099 | ev_embed *w = (ev_embed *)(((char *)fork_w) - offsetof (ev_embed, fork)); |
4971 | |
5100 | |
… | |
… | |
4978 | ev_run (EV_A_ EVRUN_NOWAIT); |
5107 | ev_run (EV_A_ EVRUN_NOWAIT); |
4979 | } |
5108 | } |
4980 | |
5109 | |
4981 | ev_embed_start (EV_A_ w); |
5110 | ev_embed_start (EV_A_ w); |
4982 | } |
5111 | } |
|
|
5112 | #endif |
4983 | |
5113 | |
4984 | #if 0 |
5114 | #if 0 |
4985 | static void |
5115 | static void |
4986 | embed_idle_cb (EV_P_ ev_idle *idle, int revents) |
5116 | embed_idle_cb (EV_P_ ev_idle *idle, int revents) |
4987 | { |
5117 | { |
… | |
… | |
5008 | |
5138 | |
5009 | ev_prepare_init (&w->prepare, embed_prepare_cb); |
5139 | ev_prepare_init (&w->prepare, embed_prepare_cb); |
5010 | ev_set_priority (&w->prepare, EV_MINPRI); |
5140 | ev_set_priority (&w->prepare, EV_MINPRI); |
5011 | ev_prepare_start (EV_A_ &w->prepare); |
5141 | ev_prepare_start (EV_A_ &w->prepare); |
5012 | |
5142 | |
|
|
5143 | #if EV_FORK_ENABLE |
5013 | ev_fork_init (&w->fork, embed_fork_cb); |
5144 | ev_fork_init (&w->fork, embed_fork_cb); |
5014 | ev_fork_start (EV_A_ &w->fork); |
5145 | ev_fork_start (EV_A_ &w->fork); |
|
|
5146 | #endif |
5015 | |
5147 | |
5016 | /*ev_idle_init (&w->idle, e,bed_idle_cb);*/ |
5148 | /*ev_idle_init (&w->idle, e,bed_idle_cb);*/ |
5017 | |
5149 | |
5018 | ev_start (EV_A_ (W)w, 1); |
5150 | ev_start (EV_A_ (W)w, 1); |
5019 | |
5151 | |
… | |
… | |
5029 | |
5161 | |
5030 | EV_FREQUENT_CHECK; |
5162 | EV_FREQUENT_CHECK; |
5031 | |
5163 | |
5032 | ev_io_stop (EV_A_ &w->io); |
5164 | ev_io_stop (EV_A_ &w->io); |
5033 | ev_prepare_stop (EV_A_ &w->prepare); |
5165 | ev_prepare_stop (EV_A_ &w->prepare); |
|
|
5166 | #if EV_FORK_ENABLE |
5034 | ev_fork_stop (EV_A_ &w->fork); |
5167 | ev_fork_stop (EV_A_ &w->fork); |
|
|
5168 | #endif |
5035 | |
5169 | |
5036 | ev_stop (EV_A_ (W)w); |
5170 | ev_stop (EV_A_ (W)w); |
5037 | |
5171 | |
5038 | EV_FREQUENT_CHECK; |
5172 | EV_FREQUENT_CHECK; |
5039 | } |
5173 | } |