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

Comparing libev/ev.c (file contents):
Revision 1.87 by root, Sat Nov 10 03:36:15 2007 UTC vs.
Revision 1.117 by ayin, Thu Nov 15 17:15:56 2007 UTC

35 35
36#ifndef EV_STANDALONE 36#ifndef EV_STANDALONE
37# include "config.h" 37# include "config.h"
38 38
39# if HAVE_CLOCK_GETTIME 39# if HAVE_CLOCK_GETTIME
40# ifndef EV_USE_MONOTONIC
40# define EV_USE_MONOTONIC 1 41# define EV_USE_MONOTONIC 1
42# endif
43# ifndef EV_USE_REALTIME
41# define EV_USE_REALTIME 1 44# define EV_USE_REALTIME 1
45# endif
42# endif 46# endif
43 47
44# if HAVE_SELECT && HAVE_SYS_SELECT_H 48# if HAVE_SELECT && HAVE_SYS_SELECT_H && !defined (EV_USE_SELECT)
45# define EV_USE_SELECT 1 49# define EV_USE_SELECT 1
46# endif 50# endif
47 51
48# if HAVE_POLL && HAVE_POLL_H 52# if HAVE_POLL && HAVE_POLL_H && !defined (EV_USE_POLL)
49# define EV_USE_POLL 1 53# define EV_USE_POLL 1
50# endif 54# endif
51 55
52# if HAVE_EPOLL && HAVE_EPOLL_CTL && HAVE_SYS_EPOLL_H 56# if HAVE_EPOLL_CTL && HAVE_SYS_EPOLL_H && !defined (EV_USE_EPOLL)
53# define EV_USE_EPOLL 1 57# define EV_USE_EPOLL 1
54# endif 58# endif
55 59
56# if HAVE_KQUEUE && HAVE_WORKING_KQUEUE && HAVE_SYS_EVENT_H && HAVE_SYS_QUEUE_H 60# if HAVE_KQUEUE && HAVE_SYS_EVENT_H && HAVE_SYS_QUEUE_H && !defined (EV_USE_KQUEUE)
57# define EV_USE_KQUEUE 1 61# define EV_USE_KQUEUE 1
58# endif 62# endif
59 63
60#endif 64#endif
61 65
71#include <sys/types.h> 75#include <sys/types.h>
72#include <time.h> 76#include <time.h>
73 77
74#include <signal.h> 78#include <signal.h>
75 79
76#ifndef WIN32 80#ifndef _WIN32
77# include <unistd.h> 81# include <unistd.h>
78# include <sys/time.h> 82# include <sys/time.h>
79# include <sys/wait.h> 83# include <sys/wait.h>
84#else
85# define WIN32_LEAN_AND_MEAN
86# include <windows.h>
87# ifndef EV_SELECT_IS_WINSOCKET
88# define EV_SELECT_IS_WINSOCKET 1
80#endif 89# endif
90#endif
91
81/**/ 92/**/
82 93
83#ifndef EV_USE_MONOTONIC 94#ifndef EV_USE_MONOTONIC
84# define EV_USE_MONOTONIC 1 95# define EV_USE_MONOTONIC 1
85#endif 96#endif
86 97
87#ifndef EV_USE_SELECT 98#ifndef EV_USE_SELECT
88# define EV_USE_SELECT 1 99# define EV_USE_SELECT 1
100# define EV_SELECT_USE_FD_SET 1
89#endif 101#endif
90 102
91#ifndef EV_USE_POLL 103#ifndef EV_USE_POLL
92# define EV_USE_POLL 0 /* poll is usually slower than select, and not as well tested */ 104# ifdef _WIN32
105# define EV_USE_POLL 0
106# else
107# define EV_USE_POLL 1
108# endif
93#endif 109#endif
94 110
95#ifndef EV_USE_EPOLL 111#ifndef EV_USE_EPOLL
96# define EV_USE_EPOLL 0 112# define EV_USE_EPOLL 0
97#endif 113#endif
98 114
99#ifndef EV_USE_KQUEUE 115#ifndef EV_USE_KQUEUE
100# define EV_USE_KQUEUE 0 116# define EV_USE_KQUEUE 0
101#endif 117#endif
102 118
103#ifndef EV_USE_WIN32
104# ifdef WIN32
105# define EV_USE_WIN32 0 /* it does not exist, use select */
106# undef EV_USE_SELECT
107# define EV_USE_SELECT 1
108# else
109# define EV_USE_WIN32 0
110# endif
111#endif
112
113#ifndef EV_USE_REALTIME 119#ifndef EV_USE_REALTIME
114# define EV_USE_REALTIME 1 120# define EV_USE_REALTIME 1
115#endif 121#endif
116 122
117/**/ 123/**/
124
125/* darwin simply cannot be helped */
126#ifdef __APPLE__
127# undef EV_USE_POLL
128# undef EV_USE_KQUEUE
129#endif
118 130
119#ifndef CLOCK_MONOTONIC 131#ifndef CLOCK_MONOTONIC
120# undef EV_USE_MONOTONIC 132# undef EV_USE_MONOTONIC
121# define EV_USE_MONOTONIC 0 133# define EV_USE_MONOTONIC 0
122#endif 134#endif
123 135
124#ifndef CLOCK_REALTIME 136#ifndef CLOCK_REALTIME
125# undef EV_USE_REALTIME 137# undef EV_USE_REALTIME
126# define EV_USE_REALTIME 0 138# define EV_USE_REALTIME 0
139#endif
140
141#if EV_SELECT_IS_WINSOCKET
142# include <winsock.h>
127#endif 143#endif
128 144
129/**/ 145/**/
130 146
131#define MIN_TIMEJUMP 1. /* minimum timejump that gets detected (if monotonic clock available) */ 147#define MIN_TIMEJUMP 1. /* minimum timejump that gets detected (if monotonic clock available) */
151#define expect_true(expr) expect ((expr) != 0, 1) 167#define expect_true(expr) expect ((expr) != 0, 1)
152 168
153#define NUMPRI (EV_MAXPRI - EV_MINPRI + 1) 169#define NUMPRI (EV_MAXPRI - EV_MINPRI + 1)
154#define ABSPRI(w) ((w)->priority - EV_MINPRI) 170#define ABSPRI(w) ((w)->priority - EV_MINPRI)
155 171
172#define EMPTY0 /* required for microsofts broken pseudo-c compiler */
173#define EMPTY2(a,b) /* used to suppress some warnings */
174
156typedef struct ev_watcher *W; 175typedef struct ev_watcher *W;
157typedef struct ev_watcher_list *WL; 176typedef struct ev_watcher_list *WL;
158typedef struct ev_watcher_time *WT; 177typedef struct ev_watcher_time *WT;
159 178
160static int have_monotonic; /* did clock_gettime (CLOCK_MONOTONIC) work? */ 179static int have_monotonic; /* did clock_gettime (CLOCK_MONOTONIC) work? */
161 180
181#ifdef _WIN32
162#include "ev_win32.c" 182# include "ev_win32.c"
183#endif
163 184
164/*****************************************************************************/ 185/*****************************************************************************/
165 186
166static void (*syserr_cb)(const char *msg); 187static void (*syserr_cb)(const char *msg);
167 188
214typedef struct 235typedef struct
215{ 236{
216 WL head; 237 WL head;
217 unsigned char events; 238 unsigned char events;
218 unsigned char reify; 239 unsigned char reify;
240#if EV_SELECT_IS_WINSOCKET
241 SOCKET handle;
242#endif
219} ANFD; 243} ANFD;
220 244
221typedef struct 245typedef struct
222{ 246{
223 W w; 247 W w;
227#if EV_MULTIPLICITY 251#if EV_MULTIPLICITY
228 252
229 struct ev_loop 253 struct ev_loop
230 { 254 {
231 ev_tstamp ev_rt_now; 255 ev_tstamp ev_rt_now;
256 #define ev_rt_now ((loop)->ev_rt_now)
232 #define VAR(name,decl) decl; 257 #define VAR(name,decl) decl;
233 #include "ev_vars.h" 258 #include "ev_vars.h"
234 #undef VAR 259 #undef VAR
235 }; 260 };
236 #include "ev_wrap.h" 261 #include "ev_wrap.h"
237 262
238 struct ev_loop default_loop_struct; 263 static struct ev_loop default_loop_struct;
239 static struct ev_loop *default_loop; 264 struct ev_loop *ev_default_loop_ptr;
240 265
241#else 266#else
242 267
243 ev_tstamp ev_rt_now; 268 ev_tstamp ev_rt_now;
244 #define VAR(name,decl) static decl; 269 #define VAR(name,decl) static decl;
245 #include "ev_vars.h" 270 #include "ev_vars.h"
246 #undef VAR 271 #undef VAR
247 272
248 static int default_loop; 273 static int ev_default_loop_ptr;
249 274
250#endif 275#endif
251 276
252/*****************************************************************************/ 277/*****************************************************************************/
253 278
254inline ev_tstamp 279ev_tstamp
255ev_time (void) 280ev_time (void)
256{ 281{
257#if EV_USE_REALTIME 282#if EV_USE_REALTIME
258 struct timespec ts; 283 struct timespec ts;
259 clock_gettime (CLOCK_REALTIME, &ts); 284 clock_gettime (CLOCK_REALTIME, &ts);
286{ 311{
287 return ev_rt_now; 312 return ev_rt_now;
288} 313}
289#endif 314#endif
290 315
291#define array_roundsize(type,n) ((n) | 4 & ~3) 316#define array_roundsize(type,n) (((n) | 4) & ~3)
292 317
293#define array_needsize(type,base,cur,cnt,init) \ 318#define array_needsize(type,base,cur,cnt,init) \
294 if (expect_false ((cnt) > cur)) \ 319 if (expect_false ((cnt) > cur)) \
295 { \ 320 { \
296 int newcnt = cur; \ 321 int newcnt = cur; \
311 stem ## max = array_roundsize (stem ## cnt >> 1); \ 336 stem ## max = array_roundsize (stem ## cnt >> 1); \
312 base = (type *)ev_realloc (base, sizeof (type) * (stem ## max));\ 337 base = (type *)ev_realloc (base, sizeof (type) * (stem ## max));\
313 fprintf (stderr, "slimmed down " # stem " to %d\n", stem ## max);/*D*/\ 338 fprintf (stderr, "slimmed down " # stem " to %d\n", stem ## max);/*D*/\
314 } 339 }
315 340
316/* microsoft's pseudo-c is quite far from C as the rest of the world and the standard knows it */
317/* bringing us everlasting joy in form of stupid extra macros that are not required in C */
318#define array_free_microshit(stem) \
319 ev_free (stem ## s); stem ## cnt = stem ## max = 0;
320
321#define array_free(stem, idx) \ 341#define array_free(stem, idx) \
322 ev_free (stem ## s idx); stem ## cnt idx = stem ## max idx = 0; 342 ev_free (stem ## s idx); stem ## cnt idx = stem ## max idx = 0;
323 343
324/*****************************************************************************/ 344/*****************************************************************************/
325 345
346 pendings [ABSPRI (w_)][w_->pending - 1].events |= revents; 366 pendings [ABSPRI (w_)][w_->pending - 1].events |= revents;
347 return; 367 return;
348 } 368 }
349 369
350 w_->pending = ++pendingcnt [ABSPRI (w_)]; 370 w_->pending = ++pendingcnt [ABSPRI (w_)];
351 array_needsize (ANPENDING, pendings [ABSPRI (w_)], pendingmax [ABSPRI (w_)], pendingcnt [ABSPRI (w_)], (void)); 371 array_needsize (ANPENDING, pendings [ABSPRI (w_)], pendingmax [ABSPRI (w_)], pendingcnt [ABSPRI (w_)], EMPTY2);
352 pendings [ABSPRI (w_)][w_->pending - 1].w = w_; 372 pendings [ABSPRI (w_)][w_->pending - 1].w = w_;
353 pendings [ABSPRI (w_)][w_->pending - 1].events = revents; 373 pendings [ABSPRI (w_)][w_->pending - 1].events = revents;
354} 374}
355 375
356static void 376static void
399 int events = 0; 419 int events = 0;
400 420
401 for (w = (struct ev_io *)anfd->head; w; w = (struct ev_io *)((WL)w)->next) 421 for (w = (struct ev_io *)anfd->head; w; w = (struct ev_io *)((WL)w)->next)
402 events |= w->events; 422 events |= w->events;
403 423
424#if EV_SELECT_IS_WINSOCKET
425 if (events)
426 {
427 unsigned long argp;
428 anfd->handle = _get_osfhandle (fd);
429 assert (("libev only supports socket fds in this configuration", ioctlsocket (anfd->handle, FIONREAD, &argp) == 0));
430 }
431#endif
432
404 anfd->reify = 0; 433 anfd->reify = 0;
405 434
406 method_modify (EV_A_ fd, anfd->events, events); 435 method_modify (EV_A_ fd, anfd->events, events);
407 anfd->events = events; 436 anfd->events = events;
408 } 437 }
417 return; 446 return;
418 447
419 anfds [fd].reify = 1; 448 anfds [fd].reify = 1;
420 449
421 ++fdchangecnt; 450 ++fdchangecnt;
422 array_needsize (int, fdchanges, fdchangemax, fdchangecnt, (void)); 451 array_needsize (int, fdchanges, fdchangemax, fdchangecnt, EMPTY2);
423 fdchanges [fdchangecnt - 1] = fd; 452 fdchanges [fdchangecnt - 1] = fd;
424} 453}
425 454
426static void 455static void
427fd_kill (EV_P_ int fd) 456fd_kill (EV_P_ int fd)
436} 465}
437 466
438static int 467static int
439fd_valid (int fd) 468fd_valid (int fd)
440{ 469{
441#ifdef WIN32 470#ifdef _WIN32
442 return !!win32_get_osfhandle (fd); 471 return _get_osfhandle (fd) != -1;
443#else 472#else
444 return fcntl (fd, F_GETFD) != -1; 473 return fcntl (fd, F_GETFD) != -1;
445#endif 474#endif
446} 475}
447 476
528 heap [k] = w; 557 heap [k] = w;
529 ((W)heap [k])->active = k + 1; 558 ((W)heap [k])->active = k + 1;
530} 559}
531 560
532inline void 561inline void
533adjustheap (WT *heap, int N, int k, ev_tstamp at) 562adjustheap (WT *heap, int N, int k)
534{ 563{
535 ev_tstamp old_at = heap [k]->at; 564 upheap (heap, k);
536 heap [k]->at = at;
537
538 if (old_at < at)
539 downheap (heap, N, k); 565 downheap (heap, N, k);
540 else
541 upheap (heap, k);
542} 566}
543 567
544/*****************************************************************************/ 568/*****************************************************************************/
545 569
546typedef struct 570typedef struct
569} 593}
570 594
571static void 595static void
572sighandler (int signum) 596sighandler (int signum)
573{ 597{
574#if WIN32 598#if _WIN32
575 signal (signum, sighandler); 599 signal (signum, sighandler);
576#endif 600#endif
577 601
578 signals [signum - 1].gotsig = 1; 602 signals [signum - 1].gotsig = 1;
579 603
580 if (!gotsig) 604 if (!gotsig)
581 { 605 {
582 int old_errno = errno; 606 int old_errno = errno;
583 gotsig = 1; 607 gotsig = 1;
584#ifdef WIN32
585 send (sigpipe [1], &signum, 1, MSG_DONTWAIT);
586#else
587 write (sigpipe [1], &signum, 1); 608 write (sigpipe [1], &signum, 1);
588#endif
589 errno = old_errno; 609 errno = old_errno;
590 } 610 }
591} 611}
592 612
593void 613void
594ev_feed_signal_event (EV_P_ int signum) 614ev_feed_signal_event (EV_P_ int signum)
595{ 615{
596 WL w; 616 WL w;
597 617
598#if EV_MULTIPLICITY 618#if EV_MULTIPLICITY
599 assert (("feeding signal events is only supported in the default loop", loop == default_loop)); 619 assert (("feeding signal events is only supported in the default loop", loop == ev_default_loop_ptr));
600#endif 620#endif
601 621
602 --signum; 622 --signum;
603 623
604 if (signum < 0 || signum >= signalmax) 624 if (signum < 0 || signum >= signalmax)
613static void 633static void
614sigcb (EV_P_ struct ev_io *iow, int revents) 634sigcb (EV_P_ struct ev_io *iow, int revents)
615{ 635{
616 int signum; 636 int signum;
617 637
618#ifdef WIN32
619 recv (sigpipe [0], &revents, 1, MSG_DONTWAIT);
620#else
621 read (sigpipe [0], &revents, 1); 638 read (sigpipe [0], &revents, 1);
622#endif
623 gotsig = 0; 639 gotsig = 0;
624 640
625 for (signum = signalmax; signum--; ) 641 for (signum = signalmax; signum--; )
626 if (signals [signum].gotsig) 642 if (signals [signum].gotsig)
627 ev_feed_signal_event (EV_A_ signum + 1); 643 ev_feed_signal_event (EV_A_ signum + 1);
628} 644}
629 645
646inline void
647fd_intern (int fd)
648{
649#ifdef _WIN32
650 int arg = 1;
651 ioctlsocket (_get_osfhandle (fd), FIONBIO, &arg);
652#else
653 fcntl (fd, F_SETFD, FD_CLOEXEC);
654 fcntl (fd, F_SETFL, O_NONBLOCK);
655#endif
656}
657
630static void 658static void
631siginit (EV_P) 659siginit (EV_P)
632{ 660{
633#ifndef WIN32 661 fd_intern (sigpipe [0]);
634 fcntl (sigpipe [0], F_SETFD, FD_CLOEXEC); 662 fd_intern (sigpipe [1]);
635 fcntl (sigpipe [1], F_SETFD, FD_CLOEXEC);
636
637 /* rather than sort out wether we really need nb, set it */
638 fcntl (sigpipe [0], F_SETFL, O_NONBLOCK);
639 fcntl (sigpipe [1], F_SETFL, O_NONBLOCK);
640#endif
641 663
642 ev_io_set (&sigev, sigpipe [0], EV_READ); 664 ev_io_set (&sigev, sigpipe [0], EV_READ);
643 ev_io_start (EV_A_ &sigev); 665 ev_io_start (EV_A_ &sigev);
644 ev_unref (EV_A); /* child watcher should not keep loop alive */ 666 ev_unref (EV_A); /* child watcher should not keep loop alive */
645} 667}
646 668
647/*****************************************************************************/ 669/*****************************************************************************/
648 670
649static struct ev_child *childs [PID_HASHSIZE]; 671static struct ev_child *childs [PID_HASHSIZE];
650 672
651#ifndef WIN32 673#ifndef _WIN32
652 674
653static struct ev_signal childev; 675static struct ev_signal childev;
654 676
655#ifndef WCONTINUED 677#ifndef WCONTINUED
656# define WCONTINUED 0 678# define WCONTINUED 0
717 739
718/* return true if we are running with elevated privileges and should ignore env variables */ 740/* return true if we are running with elevated privileges and should ignore env variables */
719static int 741static int
720enable_secure (void) 742enable_secure (void)
721{ 743{
722#ifdef WIN32 744#ifdef _WIN32
723 return 0; 745 return 0;
724#else 746#else
725 return getuid () != geteuid () 747 return getuid () != geteuid ()
726 || getgid () != getegid (); 748 || getgid () != getegid ();
727#endif 749#endif
728} 750}
729 751
730int 752unsigned int
731ev_method (EV_P) 753ev_method (EV_P)
732{ 754{
733 return method; 755 return method;
734} 756}
735 757
736static void 758static void
737loop_init (EV_P_ int methods) 759loop_init (EV_P_ unsigned int flags)
738{ 760{
739 if (!method) 761 if (!method)
740 { 762 {
741#if EV_USE_MONOTONIC 763#if EV_USE_MONOTONIC
742 { 764 {
749 ev_rt_now = ev_time (); 771 ev_rt_now = ev_time ();
750 mn_now = get_clock (); 772 mn_now = get_clock ();
751 now_floor = mn_now; 773 now_floor = mn_now;
752 rtmn_diff = ev_rt_now - mn_now; 774 rtmn_diff = ev_rt_now - mn_now;
753 775
754 if (methods == EVMETHOD_AUTO) 776 if (!(flags & EVFLAG_NOENV) && !enable_secure () && getenv ("LIBEV_FLAGS"))
755 if (!enable_secure () && getenv ("LIBEV_METHODS"))
756 methods = atoi (getenv ("LIBEV_METHODS")); 777 flags = atoi (getenv ("LIBEV_FLAGS"));
757 else 778
758 methods = EVMETHOD_ANY; 779 if (!(flags & 0x0000ffff))
780 flags |= 0x0000ffff;
759 781
760 method = 0; 782 method = 0;
761#if EV_USE_WIN32
762 if (!method && (methods & EVMETHOD_WIN32 )) method = win32_init (EV_A_ methods);
763#endif
764#if EV_USE_KQUEUE 783#if EV_USE_KQUEUE
765 if (!method && (methods & EVMETHOD_KQUEUE)) method = kqueue_init (EV_A_ methods); 784 if (!method && (flags & EVMETHOD_KQUEUE)) method = kqueue_init (EV_A_ flags);
766#endif 785#endif
767#if EV_USE_EPOLL 786#if EV_USE_EPOLL
768 if (!method && (methods & EVMETHOD_EPOLL )) method = epoll_init (EV_A_ methods); 787 if (!method && (flags & EVMETHOD_EPOLL )) method = epoll_init (EV_A_ flags);
769#endif 788#endif
770#if EV_USE_POLL 789#if EV_USE_POLL
771 if (!method && (methods & EVMETHOD_POLL )) method = poll_init (EV_A_ methods); 790 if (!method && (flags & EVMETHOD_POLL )) method = poll_init (EV_A_ flags);
772#endif 791#endif
773#if EV_USE_SELECT 792#if EV_USE_SELECT
774 if (!method && (methods & EVMETHOD_SELECT)) method = select_init (EV_A_ methods); 793 if (!method && (flags & EVMETHOD_SELECT)) method = select_init (EV_A_ flags);
775#endif 794#endif
776 795
777 ev_init (&sigev, sigcb); 796 ev_init (&sigev, sigcb);
778 ev_set_priority (&sigev, EV_MAXPRI); 797 ev_set_priority (&sigev, EV_MAXPRI);
779 } 798 }
782void 801void
783loop_destroy (EV_P) 802loop_destroy (EV_P)
784{ 803{
785 int i; 804 int i;
786 805
787#if EV_USE_WIN32
788 if (method == EVMETHOD_WIN32 ) win32_destroy (EV_A);
789#endif
790#if EV_USE_KQUEUE 806#if EV_USE_KQUEUE
791 if (method == EVMETHOD_KQUEUE) kqueue_destroy (EV_A); 807 if (method == EVMETHOD_KQUEUE) kqueue_destroy (EV_A);
792#endif 808#endif
793#if EV_USE_EPOLL 809#if EV_USE_EPOLL
794 if (method == EVMETHOD_EPOLL ) epoll_destroy (EV_A); 810 if (method == EVMETHOD_EPOLL ) epoll_destroy (EV_A);
802 818
803 for (i = NUMPRI; i--; ) 819 for (i = NUMPRI; i--; )
804 array_free (pending, [i]); 820 array_free (pending, [i]);
805 821
806 /* have to use the microsoft-never-gets-it-right macro */ 822 /* have to use the microsoft-never-gets-it-right macro */
807 array_free_microshit (fdchange); 823 array_free (fdchange, EMPTY0);
808 array_free_microshit (timer); 824 array_free (timer, EMPTY0);
809 array_free_microshit (periodic); 825#if EV_PERIODICS
810 array_free_microshit (idle); 826 array_free (periodic, EMPTY0);
811 array_free_microshit (prepare); 827#endif
812 array_free_microshit (check); 828 array_free (idle, EMPTY0);
829 array_free (prepare, EMPTY0);
830 array_free (check, EMPTY0);
813 831
814 method = 0; 832 method = 0;
815} 833}
816 834
817static void 835static void
842 postfork = 0; 860 postfork = 0;
843} 861}
844 862
845#if EV_MULTIPLICITY 863#if EV_MULTIPLICITY
846struct ev_loop * 864struct ev_loop *
847ev_loop_new (int methods) 865ev_loop_new (unsigned int flags)
848{ 866{
849 struct ev_loop *loop = (struct ev_loop *)ev_malloc (sizeof (struct ev_loop)); 867 struct ev_loop *loop = (struct ev_loop *)ev_malloc (sizeof (struct ev_loop));
850 868
851 memset (loop, 0, sizeof (struct ev_loop)); 869 memset (loop, 0, sizeof (struct ev_loop));
852 870
853 loop_init (EV_A_ methods); 871 loop_init (EV_A_ flags);
854 872
855 if (ev_method (EV_A)) 873 if (ev_method (EV_A))
856 return loop; 874 return loop;
857 875
858 return 0; 876 return 0;
873 891
874#endif 892#endif
875 893
876#if EV_MULTIPLICITY 894#if EV_MULTIPLICITY
877struct ev_loop * 895struct ev_loop *
896ev_default_loop_ (unsigned int flags)
878#else 897#else
879int 898int
899ev_default_loop (unsigned int flags)
880#endif 900#endif
881ev_default_loop (int methods)
882{ 901{
883 if (sigpipe [0] == sigpipe [1]) 902 if (sigpipe [0] == sigpipe [1])
884 if (pipe (sigpipe)) 903 if (pipe (sigpipe))
885 return 0; 904 return 0;
886 905
887 if (!default_loop) 906 if (!ev_default_loop_ptr)
888 { 907 {
889#if EV_MULTIPLICITY 908#if EV_MULTIPLICITY
890 struct ev_loop *loop = default_loop = &default_loop_struct; 909 struct ev_loop *loop = ev_default_loop_ptr = &default_loop_struct;
891#else 910#else
892 default_loop = 1; 911 ev_default_loop_ptr = 1;
893#endif 912#endif
894 913
895 loop_init (EV_A_ methods); 914 loop_init (EV_A_ flags);
896 915
897 if (ev_method (EV_A)) 916 if (ev_method (EV_A))
898 { 917 {
899 siginit (EV_A); 918 siginit (EV_A);
900 919
901#ifndef WIN32 920#ifndef _WIN32
902 ev_signal_init (&childev, childcb, SIGCHLD); 921 ev_signal_init (&childev, childcb, SIGCHLD);
903 ev_set_priority (&childev, EV_MAXPRI); 922 ev_set_priority (&childev, EV_MAXPRI);
904 ev_signal_start (EV_A_ &childev); 923 ev_signal_start (EV_A_ &childev);
905 ev_unref (EV_A); /* child watcher should not keep loop alive */ 924 ev_unref (EV_A); /* child watcher should not keep loop alive */
906#endif 925#endif
907 } 926 }
908 else 927 else
909 default_loop = 0; 928 ev_default_loop_ptr = 0;
910 } 929 }
911 930
912 return default_loop; 931 return ev_default_loop_ptr;
913} 932}
914 933
915void 934void
916ev_default_destroy (void) 935ev_default_destroy (void)
917{ 936{
918#if EV_MULTIPLICITY 937#if EV_MULTIPLICITY
919 struct ev_loop *loop = default_loop; 938 struct ev_loop *loop = ev_default_loop_ptr;
920#endif 939#endif
921 940
922#ifndef WIN32 941#ifndef _WIN32
923 ev_ref (EV_A); /* child watcher */ 942 ev_ref (EV_A); /* child watcher */
924 ev_signal_stop (EV_A_ &childev); 943 ev_signal_stop (EV_A_ &childev);
925#endif 944#endif
926 945
927 ev_ref (EV_A); /* signal watcher */ 946 ev_ref (EV_A); /* signal watcher */
935 954
936void 955void
937ev_default_fork (void) 956ev_default_fork (void)
938{ 957{
939#if EV_MULTIPLICITY 958#if EV_MULTIPLICITY
940 struct ev_loop *loop = default_loop; 959 struct ev_loop *loop = ev_default_loop_ptr;
941#endif 960#endif
942 961
943 if (method) 962 if (method)
944 postfork = 1; 963 postfork = 1;
945} 964}
987 1006
988 /* first reschedule or stop timer */ 1007 /* first reschedule or stop timer */
989 if (w->repeat) 1008 if (w->repeat)
990 { 1009 {
991 assert (("negative ev_timer repeat value found while processing timers", w->repeat > 0.)); 1010 assert (("negative ev_timer repeat value found while processing timers", w->repeat > 0.));
1011
992 ((WT)w)->at = mn_now + w->repeat; 1012 ((WT)w)->at += w->repeat;
1013 if (((WT)w)->at < mn_now)
1014 ((WT)w)->at = mn_now;
1015
993 downheap ((WT *)timers, timercnt, 0); 1016 downheap ((WT *)timers, timercnt, 0);
994 } 1017 }
995 else 1018 else
996 ev_timer_stop (EV_A_ w); /* nonrepeating: stop timer */ 1019 ev_timer_stop (EV_A_ w); /* nonrepeating: stop timer */
997 1020
998 ev_feed_event (EV_A_ (W)w, EV_TIMEOUT); 1021 ev_feed_event (EV_A_ (W)w, EV_TIMEOUT);
999 } 1022 }
1000} 1023}
1001 1024
1025#if EV_PERIODICS
1002static void 1026static void
1003periodics_reify (EV_P) 1027periodics_reify (EV_P)
1004{ 1028{
1005 while (periodiccnt && ((WT)periodics [0])->at <= ev_rt_now) 1029 while (periodiccnt && ((WT)periodics [0])->at <= ev_rt_now)
1006 { 1030 {
1009 assert (("inactive timer on periodic heap detected", ev_is_active (w))); 1033 assert (("inactive timer on periodic heap detected", ev_is_active (w)));
1010 1034
1011 /* first reschedule or stop timer */ 1035 /* first reschedule or stop timer */
1012 if (w->reschedule_cb) 1036 if (w->reschedule_cb)
1013 { 1037 {
1014 ev_tstamp at = ((WT)w)->at = w->reschedule_cb (w, ev_rt_now + 0.0001); 1038 ((WT)w)->at = w->reschedule_cb (w, ev_rt_now + 0.0001);
1015
1016 assert (("ev_periodic reschedule callback returned time in the past", ((WT)w)->at > ev_rt_now)); 1039 assert (("ev_periodic reschedule callback returned time in the past", ((WT)w)->at > ev_rt_now));
1017 downheap ((WT *)periodics, periodiccnt, 0); 1040 downheap ((WT *)periodics, periodiccnt, 0);
1018 } 1041 }
1019 else if (w->interval) 1042 else if (w->interval)
1020 { 1043 {
1047 1070
1048 /* now rebuild the heap */ 1071 /* now rebuild the heap */
1049 for (i = periodiccnt >> 1; i--; ) 1072 for (i = periodiccnt >> 1; i--; )
1050 downheap ((WT *)periodics, periodiccnt, i); 1073 downheap ((WT *)periodics, periodiccnt, i);
1051} 1074}
1075#endif
1052 1076
1053inline int 1077inline int
1054time_update_monotonic (EV_P) 1078time_update_monotonic (EV_P)
1055{ 1079{
1056 mn_now = get_clock (); 1080 mn_now = get_clock ();
1090 ev_rt_now = ev_time (); 1114 ev_rt_now = ev_time ();
1091 mn_now = get_clock (); 1115 mn_now = get_clock ();
1092 now_floor = mn_now; 1116 now_floor = mn_now;
1093 } 1117 }
1094 1118
1119# if EV_PERIODICS
1095 periodics_reschedule (EV_A); 1120 periodics_reschedule (EV_A);
1121# endif
1096 /* no timer adjustment, as the monotonic clock doesn't jump */ 1122 /* no timer adjustment, as the monotonic clock doesn't jump */
1097 /* timers_reschedule (EV_A_ rtmn_diff - odiff) */ 1123 /* timers_reschedule (EV_A_ rtmn_diff - odiff) */
1098 } 1124 }
1099 } 1125 }
1100 else 1126 else
1102 { 1128 {
1103 ev_rt_now = ev_time (); 1129 ev_rt_now = ev_time ();
1104 1130
1105 if (expect_false (mn_now > ev_rt_now || mn_now < ev_rt_now - MAX_BLOCKTIME - MIN_TIMEJUMP)) 1131 if (expect_false (mn_now > ev_rt_now || mn_now < ev_rt_now - MAX_BLOCKTIME - MIN_TIMEJUMP))
1106 { 1132 {
1133#if EV_PERIODICS
1107 periodics_reschedule (EV_A); 1134 periodics_reschedule (EV_A);
1135#endif
1108 1136
1109 /* adjust timers. this is easy, as the offset is the same for all */ 1137 /* adjust timers. this is easy, as the offset is the same for all */
1110 for (i = 0; i < timercnt; ++i) 1138 for (i = 0; i < timercnt; ++i)
1111 ((WT)timers [i])->at += ev_rt_now - mn_now; 1139 ((WT)timers [i])->at += ev_rt_now - mn_now;
1112 } 1140 }
1133ev_loop (EV_P_ int flags) 1161ev_loop (EV_P_ int flags)
1134{ 1162{
1135 double block; 1163 double block;
1136 loop_done = flags & (EVLOOP_ONESHOT | EVLOOP_NONBLOCK) ? 1 : 0; 1164 loop_done = flags & (EVLOOP_ONESHOT | EVLOOP_NONBLOCK) ? 1 : 0;
1137 1165
1138 do 1166 while (activecnt)
1139 { 1167 {
1140 /* queue check watchers (and execute them) */ 1168 /* queue check watchers (and execute them) */
1141 if (expect_false (preparecnt)) 1169 if (expect_false (preparecnt))
1142 { 1170 {
1143 queue_events (EV_A_ (W *)prepares, preparecnt, EV_PREPARE); 1171 queue_events (EV_A_ (W *)prepares, preparecnt, EV_PREPARE);
1175 { 1203 {
1176 ev_tstamp to = ((WT)timers [0])->at - mn_now + method_fudge; 1204 ev_tstamp to = ((WT)timers [0])->at - mn_now + method_fudge;
1177 if (block > to) block = to; 1205 if (block > to) block = to;
1178 } 1206 }
1179 1207
1208#if EV_PERIODICS
1180 if (periodiccnt) 1209 if (periodiccnt)
1181 { 1210 {
1182 ev_tstamp to = ((WT)periodics [0])->at - ev_rt_now + method_fudge; 1211 ev_tstamp to = ((WT)periodics [0])->at - ev_rt_now + method_fudge;
1183 if (block > to) block = to; 1212 if (block > to) block = to;
1184 } 1213 }
1214#endif
1185 1215
1186 if (block < 0.) block = 0.; 1216 if (block < 0.) block = 0.;
1187 } 1217 }
1188 1218
1189 method_poll (EV_A_ block); 1219 method_poll (EV_A_ block);
1191 /* update ev_rt_now, do magic */ 1221 /* update ev_rt_now, do magic */
1192 time_update (EV_A); 1222 time_update (EV_A);
1193 1223
1194 /* queue pending timers and reschedule them */ 1224 /* queue pending timers and reschedule them */
1195 timers_reify (EV_A); /* relative timers called last */ 1225 timers_reify (EV_A); /* relative timers called last */
1226#if EV_PERIODICS
1196 periodics_reify (EV_A); /* absolute timers called first */ 1227 periodics_reify (EV_A); /* absolute timers called first */
1228#endif
1197 1229
1198 /* queue idle watchers unless io or timers are pending */ 1230 /* queue idle watchers unless io or timers are pending */
1199 if (idlecnt && !any_pending (EV_A)) 1231 if (idlecnt && !any_pending (EV_A))
1200 queue_events (EV_A_ (W *)idles, idlecnt, EV_IDLE); 1232 queue_events (EV_A_ (W *)idles, idlecnt, EV_IDLE);
1201 1233
1202 /* queue check watchers, to be executed first */ 1234 /* queue check watchers, to be executed first */
1203 if (checkcnt) 1235 if (checkcnt)
1204 queue_events (EV_A_ (W *)checks, checkcnt, EV_CHECK); 1236 queue_events (EV_A_ (W *)checks, checkcnt, EV_CHECK);
1205 1237
1206 call_pending (EV_A); 1238 call_pending (EV_A);
1239
1240 if (loop_done)
1241 break;
1207 } 1242 }
1208 while (activecnt && !loop_done);
1209 1243
1210 if (loop_done != 2) 1244 if (loop_done != 2)
1211 loop_done = 0; 1245 loop_done = 0;
1212} 1246}
1213 1247
1292{ 1326{
1293 ev_clear_pending (EV_A_ (W)w); 1327 ev_clear_pending (EV_A_ (W)w);
1294 if (!ev_is_active (w)) 1328 if (!ev_is_active (w))
1295 return; 1329 return;
1296 1330
1331 assert (("ev_io_start called with illegal fd (must stay constant after start!)", w->fd >= 0 && w->fd < anfdmax));
1332
1297 wlist_del ((WL *)&anfds[w->fd].head, (WL)w); 1333 wlist_del ((WL *)&anfds[w->fd].head, (WL)w);
1298 ev_stop (EV_A_ (W)w); 1334 ev_stop (EV_A_ (W)w);
1299 1335
1300 fd_change (EV_A_ w->fd); 1336 fd_change (EV_A_ w->fd);
1301} 1337}
1309 ((WT)w)->at += mn_now; 1345 ((WT)w)->at += mn_now;
1310 1346
1311 assert (("ev_timer_start called with negative timer repeat value", w->repeat >= 0.)); 1347 assert (("ev_timer_start called with negative timer repeat value", w->repeat >= 0.));
1312 1348
1313 ev_start (EV_A_ (W)w, ++timercnt); 1349 ev_start (EV_A_ (W)w, ++timercnt);
1314 array_needsize (struct ev_timer *, timers, timermax, timercnt, (void)); 1350 array_needsize (struct ev_timer *, timers, timermax, timercnt, EMPTY2);
1315 timers [timercnt - 1] = w; 1351 timers [timercnt - 1] = w;
1316 upheap ((WT *)timers, timercnt - 1); 1352 upheap ((WT *)timers, timercnt - 1);
1317 1353
1318 assert (("internal timer heap corruption", timers [((W)w)->active - 1] == w)); 1354 assert (("internal timer heap corruption", timers [((W)w)->active - 1] == w));
1319} 1355}
1328 assert (("internal timer heap corruption", timers [((W)w)->active - 1] == w)); 1364 assert (("internal timer heap corruption", timers [((W)w)->active - 1] == w));
1329 1365
1330 if (((W)w)->active < timercnt--) 1366 if (((W)w)->active < timercnt--)
1331 { 1367 {
1332 timers [((W)w)->active - 1] = timers [timercnt]; 1368 timers [((W)w)->active - 1] = timers [timercnt];
1333 downheap ((WT *)timers, timercnt, ((W)w)->active - 1); 1369 adjustheap ((WT *)timers, timercnt, ((W)w)->active - 1);
1334 } 1370 }
1335 1371
1336 ((WT)w)->at = w->repeat; 1372 ((WT)w)->at -= mn_now;
1337 1373
1338 ev_stop (EV_A_ (W)w); 1374 ev_stop (EV_A_ (W)w);
1339} 1375}
1340 1376
1341void 1377void
1342ev_timer_again (EV_P_ struct ev_timer *w) 1378ev_timer_again (EV_P_ struct ev_timer *w)
1343{ 1379{
1344 if (ev_is_active (w)) 1380 if (ev_is_active (w))
1345 { 1381 {
1346 if (w->repeat) 1382 if (w->repeat)
1383 {
1384 ((WT)w)->at = mn_now + w->repeat;
1347 adjustheap ((WT *)timers, timercnt, ((W)w)->active - 1, mn_now + w->repeat); 1385 adjustheap ((WT *)timers, timercnt, ((W)w)->active - 1);
1386 }
1348 else 1387 else
1349 ev_timer_stop (EV_A_ w); 1388 ev_timer_stop (EV_A_ w);
1350 } 1389 }
1351 else if (w->repeat) 1390 else if (w->repeat)
1391 {
1392 w->at = w->repeat;
1352 ev_timer_start (EV_A_ w); 1393 ev_timer_start (EV_A_ w);
1394 }
1353} 1395}
1354 1396
1397#if EV_PERIODICS
1355void 1398void
1356ev_periodic_start (EV_P_ struct ev_periodic *w) 1399ev_periodic_start (EV_P_ struct ev_periodic *w)
1357{ 1400{
1358 if (ev_is_active (w)) 1401 if (ev_is_active (w))
1359 return; 1402 return;
1366 /* this formula differs from the one in periodic_reify because we do not always round up */ 1409 /* this formula differs from the one in periodic_reify because we do not always round up */
1367 ((WT)w)->at += ceil ((ev_rt_now - ((WT)w)->at) / w->interval) * w->interval; 1410 ((WT)w)->at += ceil ((ev_rt_now - ((WT)w)->at) / w->interval) * w->interval;
1368 } 1411 }
1369 1412
1370 ev_start (EV_A_ (W)w, ++periodiccnt); 1413 ev_start (EV_A_ (W)w, ++periodiccnt);
1371 array_needsize (struct ev_periodic *, periodics, periodicmax, periodiccnt, (void)); 1414 array_needsize (struct ev_periodic *, periodics, periodicmax, periodiccnt, EMPTY2);
1372 periodics [periodiccnt - 1] = w; 1415 periodics [periodiccnt - 1] = w;
1373 upheap ((WT *)periodics, periodiccnt - 1); 1416 upheap ((WT *)periodics, periodiccnt - 1);
1374 1417
1375 assert (("internal periodic heap corruption", periodics [((W)w)->active - 1] == w)); 1418 assert (("internal periodic heap corruption", periodics [((W)w)->active - 1] == w));
1376} 1419}
1385 assert (("internal periodic heap corruption", periodics [((W)w)->active - 1] == w)); 1428 assert (("internal periodic heap corruption", periodics [((W)w)->active - 1] == w));
1386 1429
1387 if (((W)w)->active < periodiccnt--) 1430 if (((W)w)->active < periodiccnt--)
1388 { 1431 {
1389 periodics [((W)w)->active - 1] = periodics [periodiccnt]; 1432 periodics [((W)w)->active - 1] = periodics [periodiccnt];
1390 downheap ((WT *)periodics, periodiccnt, ((W)w)->active - 1); 1433 adjustheap ((WT *)periodics, periodiccnt, ((W)w)->active - 1);
1391 } 1434 }
1392 1435
1393 ev_stop (EV_A_ (W)w); 1436 ev_stop (EV_A_ (W)w);
1394} 1437}
1395 1438
1398{ 1441{
1399 /* TODO: use adjustheap and recalculation */ 1442 /* TODO: use adjustheap and recalculation */
1400 ev_periodic_stop (EV_A_ w); 1443 ev_periodic_stop (EV_A_ w);
1401 ev_periodic_start (EV_A_ w); 1444 ev_periodic_start (EV_A_ w);
1402} 1445}
1446#endif
1403 1447
1404void 1448void
1405ev_idle_start (EV_P_ struct ev_idle *w) 1449ev_idle_start (EV_P_ struct ev_idle *w)
1406{ 1450{
1407 if (ev_is_active (w)) 1451 if (ev_is_active (w))
1408 return; 1452 return;
1409 1453
1410 ev_start (EV_A_ (W)w, ++idlecnt); 1454 ev_start (EV_A_ (W)w, ++idlecnt);
1411 array_needsize (struct ev_idle *, idles, idlemax, idlecnt, (void)); 1455 array_needsize (struct ev_idle *, idles, idlemax, idlecnt, EMPTY2);
1412 idles [idlecnt - 1] = w; 1456 idles [idlecnt - 1] = w;
1413} 1457}
1414 1458
1415void 1459void
1416ev_idle_stop (EV_P_ struct ev_idle *w) 1460ev_idle_stop (EV_P_ struct ev_idle *w)
1417{ 1461{
1418 ev_clear_pending (EV_A_ (W)w); 1462 ev_clear_pending (EV_A_ (W)w);
1419 if (ev_is_active (w)) 1463 if (!ev_is_active (w))
1420 return; 1464 return;
1421 1465
1422 idles [((W)w)->active - 1] = idles [--idlecnt]; 1466 idles [((W)w)->active - 1] = idles [--idlecnt];
1423 ev_stop (EV_A_ (W)w); 1467 ev_stop (EV_A_ (W)w);
1424} 1468}
1428{ 1472{
1429 if (ev_is_active (w)) 1473 if (ev_is_active (w))
1430 return; 1474 return;
1431 1475
1432 ev_start (EV_A_ (W)w, ++preparecnt); 1476 ev_start (EV_A_ (W)w, ++preparecnt);
1433 array_needsize (struct ev_prepare *, prepares, preparemax, preparecnt, (void)); 1477 array_needsize (struct ev_prepare *, prepares, preparemax, preparecnt, EMPTY2);
1434 prepares [preparecnt - 1] = w; 1478 prepares [preparecnt - 1] = w;
1435} 1479}
1436 1480
1437void 1481void
1438ev_prepare_stop (EV_P_ struct ev_prepare *w) 1482ev_prepare_stop (EV_P_ struct ev_prepare *w)
1439{ 1483{
1440 ev_clear_pending (EV_A_ (W)w); 1484 ev_clear_pending (EV_A_ (W)w);
1441 if (ev_is_active (w)) 1485 if (!ev_is_active (w))
1442 return; 1486 return;
1443 1487
1444 prepares [((W)w)->active - 1] = prepares [--preparecnt]; 1488 prepares [((W)w)->active - 1] = prepares [--preparecnt];
1445 ev_stop (EV_A_ (W)w); 1489 ev_stop (EV_A_ (W)w);
1446} 1490}
1450{ 1494{
1451 if (ev_is_active (w)) 1495 if (ev_is_active (w))
1452 return; 1496 return;
1453 1497
1454 ev_start (EV_A_ (W)w, ++checkcnt); 1498 ev_start (EV_A_ (W)w, ++checkcnt);
1455 array_needsize (struct ev_check *, checks, checkmax, checkcnt, (void)); 1499 array_needsize (struct ev_check *, checks, checkmax, checkcnt, EMPTY2);
1456 checks [checkcnt - 1] = w; 1500 checks [checkcnt - 1] = w;
1457} 1501}
1458 1502
1459void 1503void
1460ev_check_stop (EV_P_ struct ev_check *w) 1504ev_check_stop (EV_P_ struct ev_check *w)
1461{ 1505{
1462 ev_clear_pending (EV_A_ (W)w); 1506 ev_clear_pending (EV_A_ (W)w);
1463 if (ev_is_active (w)) 1507 if (!ev_is_active (w))
1464 return; 1508 return;
1465 1509
1466 checks [((W)w)->active - 1] = checks [--checkcnt]; 1510 checks [((W)w)->active - 1] = checks [--checkcnt];
1467 ev_stop (EV_A_ (W)w); 1511 ev_stop (EV_A_ (W)w);
1468} 1512}
1473 1517
1474void 1518void
1475ev_signal_start (EV_P_ struct ev_signal *w) 1519ev_signal_start (EV_P_ struct ev_signal *w)
1476{ 1520{
1477#if EV_MULTIPLICITY 1521#if EV_MULTIPLICITY
1478 assert (("signal watchers are only supported in the default loop", loop == default_loop)); 1522 assert (("signal watchers are only supported in the default loop", loop == ev_default_loop_ptr));
1479#endif 1523#endif
1480 if (ev_is_active (w)) 1524 if (ev_is_active (w))
1481 return; 1525 return;
1482 1526
1483 assert (("ev_signal_start called with illegal signal number", w->signum > 0)); 1527 assert (("ev_signal_start called with illegal signal number", w->signum > 0));
1486 array_needsize (ANSIG, signals, signalmax, w->signum, signals_init); 1530 array_needsize (ANSIG, signals, signalmax, w->signum, signals_init);
1487 wlist_add ((WL *)&signals [w->signum - 1].head, (WL)w); 1531 wlist_add ((WL *)&signals [w->signum - 1].head, (WL)w);
1488 1532
1489 if (!((WL)w)->next) 1533 if (!((WL)w)->next)
1490 { 1534 {
1491#if WIN32 1535#if _WIN32
1492 signal (w->signum, sighandler); 1536 signal (w->signum, sighandler);
1493#else 1537#else
1494 struct sigaction sa; 1538 struct sigaction sa;
1495 sa.sa_handler = sighandler; 1539 sa.sa_handler = sighandler;
1496 sigfillset (&sa.sa_mask); 1540 sigfillset (&sa.sa_mask);
1516 1560
1517void 1561void
1518ev_child_start (EV_P_ struct ev_child *w) 1562ev_child_start (EV_P_ struct ev_child *w)
1519{ 1563{
1520#if EV_MULTIPLICITY 1564#if EV_MULTIPLICITY
1521 assert (("child watchers are only supported in the default loop", loop == default_loop)); 1565 assert (("child watchers are only supported in the default loop", loop == ev_default_loop_ptr));
1522#endif 1566#endif
1523 if (ev_is_active (w)) 1567 if (ev_is_active (w))
1524 return; 1568 return;
1525 1569
1526 ev_start (EV_A_ (W)w, 1); 1570 ev_start (EV_A_ (W)w, 1);
1529 1573
1530void 1574void
1531ev_child_stop (EV_P_ struct ev_child *w) 1575ev_child_stop (EV_P_ struct ev_child *w)
1532{ 1576{
1533 ev_clear_pending (EV_A_ (W)w); 1577 ev_clear_pending (EV_A_ (W)w);
1534 if (ev_is_active (w)) 1578 if (!ev_is_active (w))
1535 return; 1579 return;
1536 1580
1537 wlist_del ((WL *)&childs [w->pid & (PID_HASHSIZE - 1)], (WL)w); 1581 wlist_del ((WL *)&childs [w->pid & (PID_HASHSIZE - 1)], (WL)w);
1538 ev_stop (EV_A_ (W)w); 1582 ev_stop (EV_A_ (W)w);
1539} 1583}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines