ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libev/ev.c
(Generate patch)

Comparing libev/ev.c (file contents):
Revision 1.488 by root, Fri Dec 21 06:57:09 2018 UTC vs.
Revision 1.492 by root, Sat Jun 22 16:25:53 2019 UTC

1/* 1/*
2 * libev event processing core, watcher management 2 * libev event processing core, watcher management
3 * 3 *
4 * Copyright (c) 2007-2018 Marc Alexander Lehmann <libev@schmorp.de> 4 * Copyright (c) 2007-2019 Marc Alexander Lehmann <libev@schmorp.de>
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without modifica- 7 * Redistribution and use in source and binary forms, with or without modifica-
8 * tion, are permitted provided that the following conditions are met: 8 * tion, are permitted provided that the following conditions are met:
9 * 9 *
115# else 115# else
116# undef EV_USE_EPOLL 116# undef EV_USE_EPOLL
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
121# ifndef EV_USE_LINUXAIO
122# define EV_USE_LINUXAIO EV_FEATURE_BACKENDS
123# endif
124# else
125# undef EV_USE_LINUXAIO
126# define EV_USE_LINUXAIO 0
127# endif
128
120# if HAVE_KQUEUE && HAVE_SYS_EVENT_H 129# if HAVE_KQUEUE && HAVE_SYS_EVENT_H
121# ifndef EV_USE_KQUEUE 130# ifndef EV_USE_KQUEUE
122# define EV_USE_KQUEUE EV_FEATURE_BACKENDS 131# define EV_USE_KQUEUE EV_FEATURE_BACKENDS
123# endif 132# endif
124# else 133# else
315 324
316#ifndef EV_USE_PORT 325#ifndef EV_USE_PORT
317# define EV_USE_PORT 0 326# define EV_USE_PORT 0
318#endif 327#endif
319 328
329#ifndef EV_USE_LINUXAIO
330# if __linux /* libev currently assumes linux/aio_abi.h is always available on linux */
331# define EV_USE_LINUXAIO 1
332# else
333# define EV_USE_LINUXAIO 0
334# endif
335#endif
336
320#ifndef EV_USE_INOTIFY 337#ifndef EV_USE_INOTIFY
321# if __linux && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 4)) 338# if __linux && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 4))
322# define EV_USE_INOTIFY EV_FEATURE_OS 339# define EV_USE_INOTIFY EV_FEATURE_OS
323# else 340# else
324# define EV_USE_INOTIFY 0 341# define EV_USE_INOTIFY 0
379/* aix's poll.h seems to cause lots of trouble */ 396/* aix's poll.h seems to cause lots of trouble */
380#ifdef _AIX 397#ifdef _AIX
381/* AIX has a completely broken poll.h header */ 398/* AIX has a completely broken poll.h header */
382# undef EV_USE_POLL 399# undef EV_USE_POLL
383# define EV_USE_POLL 0 400# define EV_USE_POLL 0
401#endif
402
403#if EV_USE_LINUXAIO
404# include <linux/aio_abi.h> /* probably only needed for aio_context_t */
384#endif 405#endif
385 406
386/* on linux, we can use a (slow) syscall to avoid a dependency on pthread, */ 407/* on linux, we can use a (slow) syscall to avoid a dependency on pthread, */
387/* which makes programs even slower. might work on other unices, too. */ 408/* which makes programs even slower. might work on other unices, too. */
388#if EV_USE_CLOCK_SYSCALL 409#if EV_USE_CLOCK_SYSCALL
416 437
417#if !EV_USE_NANOSLEEP 438#if !EV_USE_NANOSLEEP
418/* hp-ux has it in sys/time.h, which we unconditionally include above */ 439/* hp-ux has it in sys/time.h, which we unconditionally include above */
419# if !defined _WIN32 && !defined __hpux 440# if !defined _WIN32 && !defined __hpux
420# include <sys/select.h> 441# include <sys/select.h>
442# endif
443#endif
444
445#if EV_USE_LINUXAIO
446# include <sys/syscall.h>
447# if !SYS_io_getevents
448# undef EV_USE_LINUXAIO
449# define EV_USE_LINUXAIO 0
421# endif 450# endif
422#endif 451#endif
423 452
424#if EV_USE_INOTIFY 453#if EV_USE_INOTIFY
425# include <sys/statfs.h> 454# include <sys/statfs.h>
1543# define ABSPRI(w) (((W)w), 0) 1572# define ABSPRI(w) (((W)w), 0)
1544#else 1573#else
1545# define ABSPRI(w) (((W)w)->priority - EV_MINPRI) 1574# define ABSPRI(w) (((W)w)->priority - EV_MINPRI)
1546#endif 1575#endif
1547 1576
1548#define EMPTY /* required for microsofts broken pseudo-c compiler */ 1577#define EMPTY /* required for microsofts broken pseudo-c compiler */
1549#define EMPTY2(a,b) /* used to suppress some warnings */
1550 1578
1551typedef ev_watcher *W; 1579typedef ev_watcher *W;
1552typedef ev_watcher_list *WL; 1580typedef ev_watcher_list *WL;
1553typedef ev_watcher_time *WT; 1581typedef ev_watcher_time *WT;
1554 1582
1770typedef struct 1798typedef struct
1771{ 1799{
1772 WL head; 1800 WL head;
1773 unsigned char events; /* the events watched for */ 1801 unsigned char events; /* the events watched for */
1774 unsigned char reify; /* flag set when this ANFD needs reification (EV_ANFD_REIFY, EV__IOFDSET) */ 1802 unsigned char reify; /* flag set when this ANFD needs reification (EV_ANFD_REIFY, EV__IOFDSET) */
1775 unsigned char emask; /* the epoll backend stores the actual kernel mask in here */ 1803 unsigned char emask; /* some backends store the actual kernel mask in here */
1776 unsigned char unused; 1804 unsigned char unused;
1777#if EV_USE_EPOLL 1805#if EV_USE_EPOLL
1778 unsigned int egen; /* generation counter to counter epoll bugs */ 1806 unsigned int egen; /* generation counter to counter epoll bugs */
1779#endif 1807#endif
1780#if EV_SELECT_IS_WINSOCKET || EV_USE_IOCP 1808#if EV_SELECT_IS_WINSOCKET || EV_USE_IOCP
1961{ 1989{
1962 *cur = array_nextsize (elem, *cur, cnt); 1990 *cur = array_nextsize (elem, *cur, cnt);
1963 return ev_realloc (base, elem * *cur); 1991 return ev_realloc (base, elem * *cur);
1964} 1992}
1965 1993
1994#define array_needsize_noinit(base,count)
1995
1966#define array_init_zero(base,count) \ 1996#define array_needsize_zerofill(base,count) \
1967 memset ((void *)(base), 0, sizeof (*(base)) * (count)) 1997 memset ((void *)(base), 0, sizeof (*(base)) * (count))
1968 1998
1969#define array_needsize(type,base,cur,cnt,init) \ 1999#define array_needsize(type,base,cur,cnt,init) \
1970 if (expect_false ((cnt) > (cur))) \ 2000 if (expect_false ((cnt) > (cur))) \
1971 { \ 2001 { \
2007 if (expect_false (w_->pending)) 2037 if (expect_false (w_->pending))
2008 pendings [pri][w_->pending - 1].events |= revents; 2038 pendings [pri][w_->pending - 1].events |= revents;
2009 else 2039 else
2010 { 2040 {
2011 w_->pending = ++pendingcnt [pri]; 2041 w_->pending = ++pendingcnt [pri];
2012 array_needsize (ANPENDING, pendings [pri], pendingmax [pri], w_->pending, EMPTY2); 2042 array_needsize (ANPENDING, pendings [pri], pendingmax [pri], w_->pending, array_needsize_noinit);
2013 pendings [pri][w_->pending - 1].w = w_; 2043 pendings [pri][w_->pending - 1].w = w_;
2014 pendings [pri][w_->pending - 1].events = revents; 2044 pendings [pri][w_->pending - 1].events = revents;
2015 } 2045 }
2016 2046
2017 pendingpri = NUMPRI - 1; 2047 pendingpri = NUMPRI - 1;
2018} 2048}
2019 2049
2020inline_speed void 2050inline_speed void
2021feed_reverse (EV_P_ W w) 2051feed_reverse (EV_P_ W w)
2022{ 2052{
2023 array_needsize (W, rfeeds, rfeedmax, rfeedcnt + 1, EMPTY2); 2053 array_needsize (W, rfeeds, rfeedmax, rfeedcnt + 1, array_needsize_noinit);
2024 rfeeds [rfeedcnt++] = w; 2054 rfeeds [rfeedcnt++] = w;
2025} 2055}
2026 2056
2027inline_size void 2057inline_size void
2028feed_reverse_done (EV_P_ int revents) 2058feed_reverse_done (EV_P_ int revents)
2146 anfds [fd].reify |= flags; 2176 anfds [fd].reify |= flags;
2147 2177
2148 if (expect_true (!reify)) 2178 if (expect_true (!reify))
2149 { 2179 {
2150 ++fdchangecnt; 2180 ++fdchangecnt;
2151 array_needsize (int, fdchanges, fdchangemax, fdchangecnt, EMPTY2); 2181 array_needsize (int, fdchanges, fdchangemax, fdchangecnt, array_needsize_noinit);
2152 fdchanges [fdchangecnt - 1] = fd; 2182 fdchanges [fdchangecnt - 1] = fd;
2153 } 2183 }
2154} 2184}
2155 2185
2156/* the given fd is invalid/unusable, so make sure it doesn't hurt us anymore */ 2186/* the given fd is invalid/unusable, so make sure it doesn't hurt us anymore */
2703# include "ev_port.c" 2733# include "ev_port.c"
2704#endif 2734#endif
2705#if EV_USE_KQUEUE 2735#if EV_USE_KQUEUE
2706# include "ev_kqueue.c" 2736# include "ev_kqueue.c"
2707#endif 2737#endif
2738#if EV_USE_LINUXAIO
2739# include "ev_linuxaio.c"
2740#endif
2708#if EV_USE_EPOLL 2741#if EV_USE_EPOLL
2709# include "ev_epoll.c" 2742# include "ev_epoll.c"
2710#endif 2743#endif
2711#if EV_USE_POLL 2744#if EV_USE_POLL
2712# include "ev_poll.c" 2745# include "ev_poll.c"
2743unsigned int 2776unsigned int
2744ev_supported_backends (void) EV_NOEXCEPT 2777ev_supported_backends (void) EV_NOEXCEPT
2745{ 2778{
2746 unsigned int flags = 0; 2779 unsigned int flags = 0;
2747 2780
2748 if (EV_USE_PORT ) flags |= EVBACKEND_PORT; 2781 if (EV_USE_PORT ) flags |= EVBACKEND_PORT;
2749 if (EV_USE_KQUEUE) flags |= EVBACKEND_KQUEUE; 2782 if (EV_USE_KQUEUE ) flags |= EVBACKEND_KQUEUE;
2750 if (EV_USE_EPOLL ) flags |= EVBACKEND_EPOLL; 2783 if (EV_USE_EPOLL ) flags |= EVBACKEND_EPOLL;
2784 if (EV_USE_LINUXAIO) flags |= EVBACKEND_LINUXAIO;
2751 if (EV_USE_POLL ) flags |= EVBACKEND_POLL; 2785 if (EV_USE_POLL ) flags |= EVBACKEND_POLL;
2752 if (EV_USE_SELECT) flags |= EVBACKEND_SELECT; 2786 if (EV_USE_SELECT ) flags |= EVBACKEND_SELECT;
2753 2787
2754 return flags; 2788 return flags;
2755} 2789}
2756 2790
2757ecb_cold 2791ecb_cold
2771 flags &= ~EVBACKEND_POLL; /* poll is based on kqueue from 10.5 onwards */ 2805 flags &= ~EVBACKEND_POLL; /* poll is based on kqueue from 10.5 onwards */
2772#endif 2806#endif
2773#ifdef __FreeBSD__ 2807#ifdef __FreeBSD__
2774 flags &= ~EVBACKEND_POLL; /* poll return value is unusable (http://forums.freebsd.org/archive/index.php/t-10270.html) */ 2808 flags &= ~EVBACKEND_POLL; /* poll return value is unusable (http://forums.freebsd.org/archive/index.php/t-10270.html) */
2775#endif 2809#endif
2810
2811 /* TODO: linuxaio is very experimental */
2812 flags &= ~EVBACKEND_LINUXAIO;
2776 2813
2777 return flags; 2814 return flags;
2778} 2815}
2779 2816
2780ecb_cold 2817ecb_cold
2916 2953
2917 if (!(flags & EVBACKEND_MASK)) 2954 if (!(flags & EVBACKEND_MASK))
2918 flags |= ev_recommended_backends (); 2955 flags |= ev_recommended_backends ();
2919 2956
2920#if EV_USE_IOCP 2957#if EV_USE_IOCP
2921 if (!backend && (flags & EVBACKEND_IOCP )) backend = iocp_init (EV_A_ flags); 2958 if (!backend && (flags & EVBACKEND_IOCP )) backend = iocp_init (EV_A_ flags);
2922#endif 2959#endif
2923#if EV_USE_PORT 2960#if EV_USE_PORT
2924 if (!backend && (flags & EVBACKEND_PORT )) backend = port_init (EV_A_ flags); 2961 if (!backend && (flags & EVBACKEND_PORT )) backend = port_init (EV_A_ flags);
2925#endif 2962#endif
2926#if EV_USE_KQUEUE 2963#if EV_USE_KQUEUE
2927 if (!backend && (flags & EVBACKEND_KQUEUE)) backend = kqueue_init (EV_A_ flags); 2964 if (!backend && (flags & EVBACKEND_KQUEUE )) backend = kqueue_init (EV_A_ flags);
2965#endif
2966#if EV_USE_LINUXAIO
2967 if (!backend && (flags & EVBACKEND_LINUXAIO)) backend = linuxaio_init (EV_A_ flags);
2928#endif 2968#endif
2929#if EV_USE_EPOLL 2969#if EV_USE_EPOLL
2930 if (!backend && (flags & EVBACKEND_EPOLL )) backend = epoll_init (EV_A_ flags); 2970 if (!backend && (flags & EVBACKEND_EPOLL )) backend = epoll_init (EV_A_ flags);
2931#endif 2971#endif
2932#if EV_USE_POLL 2972#if EV_USE_POLL
2933 if (!backend && (flags & EVBACKEND_POLL )) backend = poll_init (EV_A_ flags); 2973 if (!backend && (flags & EVBACKEND_POLL )) backend = poll_init (EV_A_ flags);
2934#endif 2974#endif
2935#if EV_USE_SELECT 2975#if EV_USE_SELECT
2936 if (!backend && (flags & EVBACKEND_SELECT)) backend = select_init (EV_A_ flags); 2976 if (!backend && (flags & EVBACKEND_SELECT )) backend = select_init (EV_A_ flags);
2937#endif 2977#endif
2938 2978
2939 ev_prepare_init (&pending_w, pendingcb); 2979 ev_prepare_init (&pending_w, pendingcb);
2940 2980
2941#if EV_SIGNAL_ENABLE || EV_ASYNC_ENABLE 2981#if EV_SIGNAL_ENABLE || EV_ASYNC_ENABLE
2996 3036
2997 if (backend_fd >= 0) 3037 if (backend_fd >= 0)
2998 close (backend_fd); 3038 close (backend_fd);
2999 3039
3000#if EV_USE_IOCP 3040#if EV_USE_IOCP
3001 if (backend == EVBACKEND_IOCP ) iocp_destroy (EV_A); 3041 if (backend == EVBACKEND_IOCP ) iocp_destroy (EV_A);
3002#endif 3042#endif
3003#if EV_USE_PORT 3043#if EV_USE_PORT
3004 if (backend == EVBACKEND_PORT ) port_destroy (EV_A); 3044 if (backend == EVBACKEND_PORT ) port_destroy (EV_A);
3005#endif 3045#endif
3006#if EV_USE_KQUEUE 3046#if EV_USE_KQUEUE
3007 if (backend == EVBACKEND_KQUEUE) kqueue_destroy (EV_A); 3047 if (backend == EVBACKEND_KQUEUE ) kqueue_destroy (EV_A);
3048#endif
3049#if EV_USE_LINUXAIO
3050 if (backend == EVBACKEND_LINUXAIO) linuxaio_destroy (EV_A);
3008#endif 3051#endif
3009#if EV_USE_EPOLL 3052#if EV_USE_EPOLL
3010 if (backend == EVBACKEND_EPOLL ) epoll_destroy (EV_A); 3053 if (backend == EVBACKEND_EPOLL ) epoll_destroy (EV_A);
3011#endif 3054#endif
3012#if EV_USE_POLL 3055#if EV_USE_POLL
3013 if (backend == EVBACKEND_POLL ) poll_destroy (EV_A); 3056 if (backend == EVBACKEND_POLL ) poll_destroy (EV_A);
3014#endif 3057#endif
3015#if EV_USE_SELECT 3058#if EV_USE_SELECT
3016 if (backend == EVBACKEND_SELECT) select_destroy (EV_A); 3059 if (backend == EVBACKEND_SELECT ) select_destroy (EV_A);
3017#endif 3060#endif
3018 3061
3019 for (i = NUMPRI; i--; ) 3062 for (i = NUMPRI; i--; )
3020 { 3063 {
3021 array_free (pending, [i]); 3064 array_free (pending, [i]);
3063 3106
3064inline_size void 3107inline_size void
3065loop_fork (EV_P) 3108loop_fork (EV_P)
3066{ 3109{
3067#if EV_USE_PORT 3110#if EV_USE_PORT
3068 if (backend == EVBACKEND_PORT ) port_fork (EV_A); 3111 if (backend == EVBACKEND_PORT ) port_fork (EV_A);
3069#endif 3112#endif
3070#if EV_USE_KQUEUE 3113#if EV_USE_KQUEUE
3071 if (backend == EVBACKEND_KQUEUE) kqueue_fork (EV_A); 3114 if (backend == EVBACKEND_KQUEUE ) kqueue_fork (EV_A);
3115#endif
3116#if EV_USE_LINUXAIO
3117 if (backend == EVBACKEND_LINUXAIO) linuxaio_fork (EV_A);
3072#endif 3118#endif
3073#if EV_USE_EPOLL 3119#if EV_USE_EPOLL
3074 if (backend == EVBACKEND_EPOLL ) epoll_fork (EV_A); 3120 if (backend == EVBACKEND_EPOLL ) epoll_fork (EV_A);
3075#endif 3121#endif
3076#if EV_USE_INOTIFY 3122#if EV_USE_INOTIFY
3077 infy_fork (EV_A); 3123 infy_fork (EV_A);
3078#endif 3124#endif
3079 3125
3876 assert (("libev: ev_io_start called with illegal event mask", !(w->events & ~(EV__IOFDSET | EV_READ | EV_WRITE)))); 3922 assert (("libev: ev_io_start called with illegal event mask", !(w->events & ~(EV__IOFDSET | EV_READ | EV_WRITE))));
3877 3923
3878 EV_FREQUENT_CHECK; 3924 EV_FREQUENT_CHECK;
3879 3925
3880 ev_start (EV_A_ (W)w, 1); 3926 ev_start (EV_A_ (W)w, 1);
3881 array_needsize (ANFD, anfds, anfdmax, fd + 1, array_init_zero); 3927 array_needsize (ANFD, anfds, anfdmax, fd + 1, array_needsize_zerofill);
3882 wlist_add (&anfds[fd].head, (WL)w); 3928 wlist_add (&anfds[fd].head, (WL)w);
3883 3929
3884 /* common bug, apparently */ 3930 /* common bug, apparently */
3885 assert (("libev: ev_io_start called with corrupted watcher", ((WL)w)->next != (WL)w)); 3931 assert (("libev: ev_io_start called with corrupted watcher", ((WL)w)->next != (WL)w));
3886 3932
3923 3969
3924 EV_FREQUENT_CHECK; 3970 EV_FREQUENT_CHECK;
3925 3971
3926 ++timercnt; 3972 ++timercnt;
3927 ev_start (EV_A_ (W)w, timercnt + HEAP0 - 1); 3973 ev_start (EV_A_ (W)w, timercnt + HEAP0 - 1);
3928 array_needsize (ANHE, timers, timermax, ev_active (w) + 1, EMPTY2); 3974 array_needsize (ANHE, timers, timermax, ev_active (w) + 1, array_needsize_noinit);
3929 ANHE_w (timers [ev_active (w)]) = (WT)w; 3975 ANHE_w (timers [ev_active (w)]) = (WT)w;
3930 ANHE_at_cache (timers [ev_active (w)]); 3976 ANHE_at_cache (timers [ev_active (w)]);
3931 upheap (timers, ev_active (w)); 3977 upheap (timers, ev_active (w));
3932 3978
3933 EV_FREQUENT_CHECK; 3979 EV_FREQUENT_CHECK;
4020 4066
4021 EV_FREQUENT_CHECK; 4067 EV_FREQUENT_CHECK;
4022 4068
4023 ++periodiccnt; 4069 ++periodiccnt;
4024 ev_start (EV_A_ (W)w, periodiccnt + HEAP0 - 1); 4070 ev_start (EV_A_ (W)w, periodiccnt + HEAP0 - 1);
4025 array_needsize (ANHE, periodics, periodicmax, ev_active (w) + 1, EMPTY2); 4071 array_needsize (ANHE, periodics, periodicmax, ev_active (w) + 1, array_needsize_noinit);
4026 ANHE_w (periodics [ev_active (w)]) = (WT)w; 4072 ANHE_w (periodics [ev_active (w)]) = (WT)w;
4027 ANHE_at_cache (periodics [ev_active (w)]); 4073 ANHE_at_cache (periodics [ev_active (w)]);
4028 upheap (periodics, ev_active (w)); 4074 upheap (periodics, ev_active (w));
4029 4075
4030 EV_FREQUENT_CHECK; 4076 EV_FREQUENT_CHECK;
4615 int active = ++idlecnt [ABSPRI (w)]; 4661 int active = ++idlecnt [ABSPRI (w)];
4616 4662
4617 ++idleall; 4663 ++idleall;
4618 ev_start (EV_A_ (W)w, active); 4664 ev_start (EV_A_ (W)w, active);
4619 4665
4620 array_needsize (ev_idle *, idles [ABSPRI (w)], idlemax [ABSPRI (w)], active, EMPTY2); 4666 array_needsize (ev_idle *, idles [ABSPRI (w)], idlemax [ABSPRI (w)], active, array_needsize_noinit);
4621 idles [ABSPRI (w)][active - 1] = w; 4667 idles [ABSPRI (w)][active - 1] = w;
4622 } 4668 }
4623 4669
4624 EV_FREQUENT_CHECK; 4670 EV_FREQUENT_CHECK;
4625} 4671}
4655 return; 4701 return;
4656 4702
4657 EV_FREQUENT_CHECK; 4703 EV_FREQUENT_CHECK;
4658 4704
4659 ev_start (EV_A_ (W)w, ++preparecnt); 4705 ev_start (EV_A_ (W)w, ++preparecnt);
4660 array_needsize (ev_prepare *, prepares, preparemax, preparecnt, EMPTY2); 4706 array_needsize (ev_prepare *, prepares, preparemax, preparecnt, array_needsize_noinit);
4661 prepares [preparecnt - 1] = w; 4707 prepares [preparecnt - 1] = w;
4662 4708
4663 EV_FREQUENT_CHECK; 4709 EV_FREQUENT_CHECK;
4664} 4710}
4665 4711
4693 return; 4739 return;
4694 4740
4695 EV_FREQUENT_CHECK; 4741 EV_FREQUENT_CHECK;
4696 4742
4697 ev_start (EV_A_ (W)w, ++checkcnt); 4743 ev_start (EV_A_ (W)w, ++checkcnt);
4698 array_needsize (ev_check *, checks, checkmax, checkcnt, EMPTY2); 4744 array_needsize (ev_check *, checks, checkmax, checkcnt, array_needsize_noinit);
4699 checks [checkcnt - 1] = w; 4745 checks [checkcnt - 1] = w;
4700 4746
4701 EV_FREQUENT_CHECK; 4747 EV_FREQUENT_CHECK;
4702} 4748}
4703 4749
4841 return; 4887 return;
4842 4888
4843 EV_FREQUENT_CHECK; 4889 EV_FREQUENT_CHECK;
4844 4890
4845 ev_start (EV_A_ (W)w, ++forkcnt); 4891 ev_start (EV_A_ (W)w, ++forkcnt);
4846 array_needsize (ev_fork *, forks, forkmax, forkcnt, EMPTY2); 4892 array_needsize (ev_fork *, forks, forkmax, forkcnt, array_needsize_noinit);
4847 forks [forkcnt - 1] = w; 4893 forks [forkcnt - 1] = w;
4848 4894
4849 EV_FREQUENT_CHECK; 4895 EV_FREQUENT_CHECK;
4850} 4896}
4851 4897
4879 return; 4925 return;
4880 4926
4881 EV_FREQUENT_CHECK; 4927 EV_FREQUENT_CHECK;
4882 4928
4883 ev_start (EV_A_ (W)w, ++cleanupcnt); 4929 ev_start (EV_A_ (W)w, ++cleanupcnt);
4884 array_needsize (ev_cleanup *, cleanups, cleanupmax, cleanupcnt, EMPTY2); 4930 array_needsize (ev_cleanup *, cleanups, cleanupmax, cleanupcnt, array_needsize_noinit);
4885 cleanups [cleanupcnt - 1] = w; 4931 cleanups [cleanupcnt - 1] = w;
4886 4932
4887 /* cleanup watchers should never keep a refcount on the loop */ 4933 /* cleanup watchers should never keep a refcount on the loop */
4888 ev_unref (EV_A); 4934 ev_unref (EV_A);
4889 EV_FREQUENT_CHECK; 4935 EV_FREQUENT_CHECK;
4924 evpipe_init (EV_A); 4970 evpipe_init (EV_A);
4925 4971
4926 EV_FREQUENT_CHECK; 4972 EV_FREQUENT_CHECK;
4927 4973
4928 ev_start (EV_A_ (W)w, ++asynccnt); 4974 ev_start (EV_A_ (W)w, ++asynccnt);
4929 array_needsize (ev_async *, asyncs, asyncmax, asynccnt, EMPTY2); 4975 array_needsize (ev_async *, asyncs, asyncmax, asynccnt, array_needsize_noinit);
4930 asyncs [asynccnt - 1] = w; 4976 asyncs [asynccnt - 1] = w;
4931 4977
4932 EV_FREQUENT_CHECK; 4978 EV_FREQUENT_CHECK;
4933} 4979}
4934 4980
5002 5048
5003void 5049void
5004ev_once (EV_P_ int fd, int events, ev_tstamp timeout, void (*cb)(int revents, void *arg), void *arg) EV_NOEXCEPT 5050ev_once (EV_P_ int fd, int events, ev_tstamp timeout, void (*cb)(int revents, void *arg), void *arg) EV_NOEXCEPT
5005{ 5051{
5006 struct ev_once *once = (struct ev_once *)ev_malloc (sizeof (struct ev_once)); 5052 struct ev_once *once = (struct ev_once *)ev_malloc (sizeof (struct ev_once));
5007
5008 if (expect_false (!once))
5009 {
5010 cb (EV_ERROR | EV_READ | EV_WRITE | EV_TIMER, arg);
5011 return;
5012 }
5013 5053
5014 once->cb = cb; 5054 once->cb = cb;
5015 once->arg = arg; 5055 once->arg = arg;
5016 5056
5017 ev_init (&once->io, once_cb_io); 5057 ev_init (&once->io, once_cb_io);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines