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

Comparing libev/ev.c (file contents):
Revision 1.282 by root, Sat Mar 28 22:17:17 2009 UTC vs.
Revision 1.293 by root, Mon Jun 29 18:46:52 2009 UTC

57# endif 57# endif
58# ifndef EV_USE_MONOTONIC 58# ifndef EV_USE_MONOTONIC
59# define EV_USE_MONOTONIC 1 59# define EV_USE_MONOTONIC 1
60# endif 60# endif
61# endif 61# endif
62# elif !defined(EV_USE_CLOCK_SYSCALL)
63# define EV_USE_CLOCK_SYSCALL 0
62# endif 64# endif
63 65
64# if HAVE_CLOCK_GETTIME 66# if HAVE_CLOCK_GETTIME
65# ifndef EV_USE_MONOTONIC 67# ifndef EV_USE_MONOTONIC
66# define EV_USE_MONOTONIC 1 68# define EV_USE_MONOTONIC 1
282 284
283#ifndef EV_HEAP_CACHE_AT 285#ifndef EV_HEAP_CACHE_AT
284# define EV_HEAP_CACHE_AT !EV_MINIMAL 286# define EV_HEAP_CACHE_AT !EV_MINIMAL
285#endif 287#endif
286 288
289/* on linux, we can use a (slow) syscall to avoid a dependency on pthread, */
290/* which makes programs even slower. might work on other unices, too. */
291#if EV_USE_CLOCK_SYSCALL
292# include <syscall.h>
293# ifdef SYS_clock_gettime
294# define clock_gettime(id, ts) syscall (SYS_clock_gettime, (id), (ts))
295# undef EV_USE_MONOTONIC
296# define EV_USE_MONOTONIC 1
297# else
298# undef EV_USE_CLOCK_SYSCALL
299# define EV_USE_CLOCK_SYSCALL 0
300# endif
301#endif
302
287/* this block fixes any misconfiguration where we know we run into trouble otherwise */ 303/* this block fixes any misconfiguration where we know we run into trouble otherwise */
288 304
289#ifndef CLOCK_MONOTONIC 305#ifndef CLOCK_MONOTONIC
290# undef EV_USE_MONOTONIC 306# undef EV_USE_MONOTONIC
291# define EV_USE_MONOTONIC 0 307# define EV_USE_MONOTONIC 0
320 336
321#if EV_SELECT_IS_WINSOCKET 337#if EV_SELECT_IS_WINSOCKET
322# include <winsock.h> 338# include <winsock.h>
323#endif 339#endif
324 340
325/* on linux, we can use a (slow) syscall to avoid a dependency on pthread, */
326/* which makes programs even slower. might work on other unices, too. */
327#if EV_USE_CLOCK_SYSCALL
328# include <syscall.h>
329# define clock_gettime(id, ts) syscall (SYS_clock_gettime, (id), (ts))
330# undef EV_USE_MONOTONIC
331# define EV_USE_MONOTONIC 1
332#endif
333
334#if EV_USE_EVENTFD 341#if EV_USE_EVENTFD
335/* our minimum requirement is glibc 2.7 which has the stub, but not the header */ 342/* our minimum requirement is glibc 2.7 which has the stub, but not the header */
336# include <stdint.h> 343# include <stdint.h>
337# ifdef __cplusplus 344# ifdef __cplusplus
338extern "C" { 345extern "C" {
478#define ev_malloc(size) ev_realloc (0, (size)) 485#define ev_malloc(size) ev_realloc (0, (size))
479#define ev_free(ptr) ev_realloc ((ptr), 0) 486#define ev_free(ptr) ev_realloc ((ptr), 0)
480 487
481/*****************************************************************************/ 488/*****************************************************************************/
482 489
490/* file descriptor info structure */
483typedef struct 491typedef struct
484{ 492{
485 WL head; 493 WL head;
486 unsigned char events; 494 unsigned char events; /* the events watched for */
487 unsigned char reify; 495 unsigned char reify; /* flag set when this ANFD needs reification */
488 unsigned char emask; /* the epoll backend stores the actual kernel mask in here */ 496 unsigned char emask; /* the epoll backend stores the actual kernel mask in here */
489 unsigned char unused; 497 unsigned char unused;
490#if EV_USE_EPOLL 498#if EV_USE_EPOLL
491 unsigned int egen; /* generation counter to counter epoll bugs */ 499 unsigned int egen; /* generation counter to counter epoll bugs */
492#endif 500#endif
493#if EV_SELECT_IS_WINSOCKET 501#if EV_SELECT_IS_WINSOCKET
494 SOCKET handle; 502 SOCKET handle;
495#endif 503#endif
496} ANFD; 504} ANFD;
497 505
506/* stores the pending event set for a given watcher */
498typedef struct 507typedef struct
499{ 508{
500 W w; 509 W w;
501 int events; 510 int events; /* the pending event set for the given watcher */
502} ANPENDING; 511} ANPENDING;
503 512
504#if EV_USE_INOTIFY 513#if EV_USE_INOTIFY
505/* hash table entry per inotify-id */ 514/* hash table entry per inotify-id */
506typedef struct 515typedef struct
509} ANFS; 518} ANFS;
510#endif 519#endif
511 520
512/* Heap Entry */ 521/* Heap Entry */
513#if EV_HEAP_CACHE_AT 522#if EV_HEAP_CACHE_AT
523 /* a heap element */
514 typedef struct { 524 typedef struct {
515 ev_tstamp at; 525 ev_tstamp at;
516 WT w; 526 WT w;
517 } ANHE; 527 } ANHE;
518 528
519 #define ANHE_w(he) (he).w /* access watcher, read-write */ 529 #define ANHE_w(he) (he).w /* access watcher, read-write */
520 #define ANHE_at(he) (he).at /* access cached at, read-only */ 530 #define ANHE_at(he) (he).at /* access cached at, read-only */
521 #define ANHE_at_cache(he) (he).at = (he).w->at /* update at from watcher */ 531 #define ANHE_at_cache(he) (he).at = (he).w->at /* update at from watcher */
522#else 532#else
533 /* a heap element */
523 typedef WT ANHE; 534 typedef WT ANHE;
524 535
525 #define ANHE_w(he) (he) 536 #define ANHE_w(he) (he)
526 #define ANHE_at(he) (he)->at 537 #define ANHE_at(he) (he)->at
527 #define ANHE_at_cache(he) 538 #define ANHE_at_cache(he)
553 564
554#endif 565#endif
555 566
556/*****************************************************************************/ 567/*****************************************************************************/
557 568
569#ifndef EV_HAVE_EV_TIME
558ev_tstamp 570ev_tstamp
559ev_time (void) 571ev_time (void)
560{ 572{
561#if EV_USE_REALTIME 573#if EV_USE_REALTIME
562 if (expect_true (have_realtime)) 574 if (expect_true (have_realtime))
569 581
570 struct timeval tv; 582 struct timeval tv;
571 gettimeofday (&tv, 0); 583 gettimeofday (&tv, 0);
572 return tv.tv_sec + tv.tv_usec * 1e-6; 584 return tv.tv_sec + tv.tv_usec * 1e-6;
573} 585}
586#endif
574 587
575ev_tstamp inline_size 588inline_size ev_tstamp
576get_clock (void) 589get_clock (void)
577{ 590{
578#if EV_USE_MONOTONIC 591#if EV_USE_MONOTONIC
579 if (expect_true (have_monotonic)) 592 if (expect_true (have_monotonic))
580 { 593 {
614 627
615 tv.tv_sec = (time_t)delay; 628 tv.tv_sec = (time_t)delay;
616 tv.tv_usec = (long)((delay - (ev_tstamp)(tv.tv_sec)) * 1e6); 629 tv.tv_usec = (long)((delay - (ev_tstamp)(tv.tv_sec)) * 1e6);
617 630
618 /* here we rely on sys/time.h + sys/types.h + unistd.h providing select */ 631 /* here we rely on sys/time.h + sys/types.h + unistd.h providing select */
619 /* somehting nto guaranteed by newer posix versions, but guaranteed */ 632 /* somehting not guaranteed by newer posix versions, but guaranteed */
620 /* by older ones */ 633 /* by older ones */
621 select (0, 0, 0, 0, &tv); 634 select (0, 0, 0, 0, &tv);
622#endif 635#endif
623 } 636 }
624} 637}
625 638
626/*****************************************************************************/ 639/*****************************************************************************/
627 640
628#define MALLOC_ROUND 4096 /* prefer to allocate in chunks of this size, must be 2**n and >> 4 longs */ 641#define MALLOC_ROUND 4096 /* prefer to allocate in chunks of this size, must be 2**n and >> 4 longs */
629 642
630int inline_size 643/* find a suitable new size for the given array, */
644/* hopefully by rounding to a ncie-to-malloc size */
645inline_size int
631array_nextsize (int elem, int cur, int cnt) 646array_nextsize (int elem, int cur, int cnt)
632{ 647{
633 int ncur = cur + 1; 648 int ncur = cur + 1;
634 649
635 do 650 do
680#define array_free(stem, idx) \ 695#define array_free(stem, idx) \
681 ev_free (stem ## s idx); stem ## cnt idx = stem ## max idx = 0; stem ## s idx = 0 696 ev_free (stem ## s idx); stem ## cnt idx = stem ## max idx = 0; stem ## s idx = 0
682 697
683/*****************************************************************************/ 698/*****************************************************************************/
684 699
700/* dummy callback for pending events */
701static void noinline
702pendingcb (EV_P_ ev_prepare *w, int revents)
703{
704}
705
685void noinline 706void noinline
686ev_feed_event (EV_P_ void *w, int revents) 707ev_feed_event (EV_P_ void *w, int revents)
687{ 708{
688 W w_ = (W)w; 709 W w_ = (W)w;
689 int pri = ABSPRI (w_); 710 int pri = ABSPRI (w_);
697 pendings [pri][w_->pending - 1].w = w_; 718 pendings [pri][w_->pending - 1].w = w_;
698 pendings [pri][w_->pending - 1].events = revents; 719 pendings [pri][w_->pending - 1].events = revents;
699 } 720 }
700} 721}
701 722
702void inline_speed 723inline_speed void
724feed_reverse (EV_P_ W w)
725{
726 array_needsize (W, rfeeds, rfeedmax, rfeedcnt + 1, EMPTY2);
727 rfeeds [rfeedcnt++] = w;
728}
729
730inline_size void
731feed_reverse_done (EV_P_ int revents)
732{
733 do
734 ev_feed_event (EV_A_ rfeeds [--rfeedcnt], revents);
735 while (rfeedcnt);
736}
737
738inline_speed void
703queue_events (EV_P_ W *events, int eventcnt, int type) 739queue_events (EV_P_ W *events, int eventcnt, int type)
704{ 740{
705 int i; 741 int i;
706 742
707 for (i = 0; i < eventcnt; ++i) 743 for (i = 0; i < eventcnt; ++i)
708 ev_feed_event (EV_A_ events [i], type); 744 ev_feed_event (EV_A_ events [i], type);
709} 745}
710 746
711/*****************************************************************************/ 747/*****************************************************************************/
712 748
713void inline_speed 749inline_speed void
714fd_event (EV_P_ int fd, int revents) 750fd_event (EV_P_ int fd, int revents)
715{ 751{
716 ANFD *anfd = anfds + fd; 752 ANFD *anfd = anfds + fd;
717 ev_io *w; 753 ev_io *w;
718 754
730{ 766{
731 if (fd >= 0 && fd < anfdmax) 767 if (fd >= 0 && fd < anfdmax)
732 fd_event (EV_A_ fd, revents); 768 fd_event (EV_A_ fd, revents);
733} 769}
734 770
735void inline_size 771/* make sure the external fd watch events are in-sync */
772/* with the kernel/libev internal state */
773inline_size void
736fd_reify (EV_P) 774fd_reify (EV_P)
737{ 775{
738 int i; 776 int i;
739 777
740 for (i = 0; i < fdchangecnt; ++i) 778 for (i = 0; i < fdchangecnt; ++i)
774 } 812 }
775 813
776 fdchangecnt = 0; 814 fdchangecnt = 0;
777} 815}
778 816
779void inline_size 817/* something about the given fd changed */
818inline_size void
780fd_change (EV_P_ int fd, int flags) 819fd_change (EV_P_ int fd, int flags)
781{ 820{
782 unsigned char reify = anfds [fd].reify; 821 unsigned char reify = anfds [fd].reify;
783 anfds [fd].reify |= flags; 822 anfds [fd].reify |= flags;
784 823
788 array_needsize (int, fdchanges, fdchangemax, fdchangecnt, EMPTY2); 827 array_needsize (int, fdchanges, fdchangemax, fdchangecnt, EMPTY2);
789 fdchanges [fdchangecnt - 1] = fd; 828 fdchanges [fdchangecnt - 1] = fd;
790 } 829 }
791} 830}
792 831
793void inline_speed 832/* the given fd is invalid/unusable, so make sure it doesn't hurt us anymore */
833inline_speed void
794fd_kill (EV_P_ int fd) 834fd_kill (EV_P_ int fd)
795{ 835{
796 ev_io *w; 836 ev_io *w;
797 837
798 while ((w = (ev_io *)anfds [fd].head)) 838 while ((w = (ev_io *)anfds [fd].head))
800 ev_io_stop (EV_A_ w); 840 ev_io_stop (EV_A_ w);
801 ev_feed_event (EV_A_ (W)w, EV_ERROR | EV_READ | EV_WRITE); 841 ev_feed_event (EV_A_ (W)w, EV_ERROR | EV_READ | EV_WRITE);
802 } 842 }
803} 843}
804 844
805int inline_size 845/* check whether the given fd is atcually valid, for error recovery */
846inline_size int
806fd_valid (int fd) 847fd_valid (int fd)
807{ 848{
808#ifdef _WIN32 849#ifdef _WIN32
809 return _get_osfhandle (fd) != -1; 850 return _get_osfhandle (fd) != -1;
810#else 851#else
873#define HEAP0 (DHEAP - 1) /* index of first element in heap */ 914#define HEAP0 (DHEAP - 1) /* index of first element in heap */
874#define HPARENT(k) ((((k) - HEAP0 - 1) / DHEAP) + HEAP0) 915#define HPARENT(k) ((((k) - HEAP0 - 1) / DHEAP) + HEAP0)
875#define UPHEAP_DONE(p,k) ((p) == (k)) 916#define UPHEAP_DONE(p,k) ((p) == (k))
876 917
877/* away from the root */ 918/* away from the root */
878void inline_speed 919inline_speed void
879downheap (ANHE *heap, int N, int k) 920downheap (ANHE *heap, int N, int k)
880{ 921{
881 ANHE he = heap [k]; 922 ANHE he = heap [k];
882 ANHE *E = heap + N + HEAP0; 923 ANHE *E = heap + N + HEAP0;
883 924
923#define HEAP0 1 964#define HEAP0 1
924#define HPARENT(k) ((k) >> 1) 965#define HPARENT(k) ((k) >> 1)
925#define UPHEAP_DONE(p,k) (!(p)) 966#define UPHEAP_DONE(p,k) (!(p))
926 967
927/* away from the root */ 968/* away from the root */
928void inline_speed 969inline_speed void
929downheap (ANHE *heap, int N, int k) 970downheap (ANHE *heap, int N, int k)
930{ 971{
931 ANHE he = heap [k]; 972 ANHE he = heap [k];
932 973
933 for (;;) 974 for (;;)
953 ev_active (ANHE_w (he)) = k; 994 ev_active (ANHE_w (he)) = k;
954} 995}
955#endif 996#endif
956 997
957/* towards the root */ 998/* towards the root */
958void inline_speed 999inline_speed void
959upheap (ANHE *heap, int k) 1000upheap (ANHE *heap, int k)
960{ 1001{
961 ANHE he = heap [k]; 1002 ANHE he = heap [k];
962 1003
963 for (;;) 1004 for (;;)
974 1015
975 heap [k] = he; 1016 heap [k] = he;
976 ev_active (ANHE_w (he)) = k; 1017 ev_active (ANHE_w (he)) = k;
977} 1018}
978 1019
979void inline_size 1020/* move an element suitably so it is in a correct place */
1021inline_size void
980adjustheap (ANHE *heap, int N, int k) 1022adjustheap (ANHE *heap, int N, int k)
981{ 1023{
982 if (k > HEAP0 && ANHE_at (heap [HPARENT (k)]) >= ANHE_at (heap [k])) 1024 if (k > HEAP0 && ANHE_at (heap [HPARENT (k)]) >= ANHE_at (heap [k]))
983 upheap (heap, k); 1025 upheap (heap, k);
984 else 1026 else
985 downheap (heap, N, k); 1027 downheap (heap, N, k);
986} 1028}
987 1029
988/* rebuild the heap: this function is used only once and executed rarely */ 1030/* rebuild the heap: this function is used only once and executed rarely */
989void inline_size 1031inline_size void
990reheap (ANHE *heap, int N) 1032reheap (ANHE *heap, int N)
991{ 1033{
992 int i; 1034 int i;
993 1035
994 /* we don't use floyds algorithm, upheap is simpler and is more cache-efficient */ 1036 /* we don't use floyds algorithm, upheap is simpler and is more cache-efficient */
997 upheap (heap, i + HEAP0); 1039 upheap (heap, i + HEAP0);
998} 1040}
999 1041
1000/*****************************************************************************/ 1042/*****************************************************************************/
1001 1043
1044/* associate signal watchers to a signal signal */
1002typedef struct 1045typedef struct
1003{ 1046{
1004 WL head; 1047 WL head;
1005 EV_ATOMIC_T gotsig; 1048 EV_ATOMIC_T gotsig;
1006} ANSIG; 1049} ANSIG;
1010 1053
1011static EV_ATOMIC_T gotsig; 1054static EV_ATOMIC_T gotsig;
1012 1055
1013/*****************************************************************************/ 1056/*****************************************************************************/
1014 1057
1015void inline_speed 1058/* used to prepare libev internal fd's */
1059/* this is not fork-safe */
1060inline_speed void
1016fd_intern (int fd) 1061fd_intern (int fd)
1017{ 1062{
1018#ifdef _WIN32 1063#ifdef _WIN32
1019 unsigned long arg = 1; 1064 unsigned long arg = 1;
1020 ioctlsocket (_get_osfhandle (fd), FIONBIO, &arg); 1065 ioctlsocket (_get_osfhandle (fd), FIONBIO, &arg);
1025} 1070}
1026 1071
1027static void noinline 1072static void noinline
1028evpipe_init (EV_P) 1073evpipe_init (EV_P)
1029{ 1074{
1030 if (!ev_is_active (&pipeev)) 1075 if (!ev_is_active (&pipe_w))
1031 { 1076 {
1032#if EV_USE_EVENTFD 1077#if EV_USE_EVENTFD
1033 if ((evfd = eventfd (0, 0)) >= 0) 1078 if ((evfd = eventfd (0, 0)) >= 0)
1034 { 1079 {
1035 evpipe [0] = -1; 1080 evpipe [0] = -1;
1036 fd_intern (evfd); 1081 fd_intern (evfd);
1037 ev_io_set (&pipeev, evfd, EV_READ); 1082 ev_io_set (&pipe_w, evfd, EV_READ);
1038 } 1083 }
1039 else 1084 else
1040#endif 1085#endif
1041 { 1086 {
1042 while (pipe (evpipe)) 1087 while (pipe (evpipe))
1043 ev_syserr ("(libev) error creating signal/async pipe"); 1088 ev_syserr ("(libev) error creating signal/async pipe");
1044 1089
1045 fd_intern (evpipe [0]); 1090 fd_intern (evpipe [0]);
1046 fd_intern (evpipe [1]); 1091 fd_intern (evpipe [1]);
1047 ev_io_set (&pipeev, evpipe [0], EV_READ); 1092 ev_io_set (&pipe_w, evpipe [0], EV_READ);
1048 } 1093 }
1049 1094
1050 ev_io_start (EV_A_ &pipeev); 1095 ev_io_start (EV_A_ &pipe_w);
1051 ev_unref (EV_A); /* watcher should not keep loop alive */ 1096 ev_unref (EV_A); /* watcher should not keep loop alive */
1052 } 1097 }
1053} 1098}
1054 1099
1055void inline_size 1100inline_size void
1056evpipe_write (EV_P_ EV_ATOMIC_T *flag) 1101evpipe_write (EV_P_ EV_ATOMIC_T *flag)
1057{ 1102{
1058 if (!*flag) 1103 if (!*flag)
1059 { 1104 {
1060 int old_errno = errno; /* save errno because write might clobber it */ 1105 int old_errno = errno; /* save errno because write might clobber it */
1073 1118
1074 errno = old_errno; 1119 errno = old_errno;
1075 } 1120 }
1076} 1121}
1077 1122
1123/* called whenever the libev signal pipe */
1124/* got some events (signal, async) */
1078static void 1125static void
1079pipecb (EV_P_ ev_io *iow, int revents) 1126pipecb (EV_P_ ev_io *iow, int revents)
1080{ 1127{
1081#if EV_USE_EVENTFD 1128#if EV_USE_EVENTFD
1082 if (evfd >= 0) 1129 if (evfd >= 0)
1164 1211
1165#ifndef WIFCONTINUED 1212#ifndef WIFCONTINUED
1166# define WIFCONTINUED(status) 0 1213# define WIFCONTINUED(status) 0
1167#endif 1214#endif
1168 1215
1169void inline_speed 1216/* handle a single child status event */
1217inline_speed void
1170child_reap (EV_P_ int chain, int pid, int status) 1218child_reap (EV_P_ int chain, int pid, int status)
1171{ 1219{
1172 ev_child *w; 1220 ev_child *w;
1173 int traced = WIFSTOPPED (status) || WIFCONTINUED (status); 1221 int traced = WIFSTOPPED (status) || WIFCONTINUED (status);
1174 1222
1187 1235
1188#ifndef WCONTINUED 1236#ifndef WCONTINUED
1189# define WCONTINUED 0 1237# define WCONTINUED 0
1190#endif 1238#endif
1191 1239
1240/* called on sigchld etc., calls waitpid */
1192static void 1241static void
1193childcb (EV_P_ ev_signal *sw, int revents) 1242childcb (EV_P_ ev_signal *sw, int revents)
1194{ 1243{
1195 int pid, status; 1244 int pid, status;
1196 1245
1321ev_set_timeout_collect_interval (EV_P_ ev_tstamp interval) 1370ev_set_timeout_collect_interval (EV_P_ ev_tstamp interval)
1322{ 1371{
1323 timeout_blocktime = interval; 1372 timeout_blocktime = interval;
1324} 1373}
1325 1374
1375/* initialise a loop structure, must be zero-initialised */
1326static void noinline 1376static void noinline
1327loop_init (EV_P_ unsigned int flags) 1377loop_init (EV_P_ unsigned int flags)
1328{ 1378{
1329 if (!backend) 1379 if (!backend)
1330 { 1380 {
1390#endif 1440#endif
1391#if EV_USE_SELECT 1441#if EV_USE_SELECT
1392 if (!backend && (flags & EVBACKEND_SELECT)) backend = select_init (EV_A_ flags); 1442 if (!backend && (flags & EVBACKEND_SELECT)) backend = select_init (EV_A_ flags);
1393#endif 1443#endif
1394 1444
1445 ev_prepare_init (&pending_w, pendingcb);
1446
1395 ev_init (&pipeev, pipecb); 1447 ev_init (&pipe_w, pipecb);
1396 ev_set_priority (&pipeev, EV_MAXPRI); 1448 ev_set_priority (&pipe_w, EV_MAXPRI);
1397 } 1449 }
1398} 1450}
1399 1451
1452/* free up a loop structure */
1400static void noinline 1453static void noinline
1401loop_destroy (EV_P) 1454loop_destroy (EV_P)
1402{ 1455{
1403 int i; 1456 int i;
1404 1457
1405 if (ev_is_active (&pipeev)) 1458 if (ev_is_active (&pipe_w))
1406 { 1459 {
1407 ev_ref (EV_A); /* signal watcher */ 1460 ev_ref (EV_A); /* signal watcher */
1408 ev_io_stop (EV_A_ &pipeev); 1461 ev_io_stop (EV_A_ &pipe_w);
1409 1462
1410#if EV_USE_EVENTFD 1463#if EV_USE_EVENTFD
1411 if (evfd >= 0) 1464 if (evfd >= 0)
1412 close (evfd); 1465 close (evfd);
1413#endif 1466#endif
1452 } 1505 }
1453 1506
1454 ev_free (anfds); anfdmax = 0; 1507 ev_free (anfds); anfdmax = 0;
1455 1508
1456 /* have to use the microsoft-never-gets-it-right macro */ 1509 /* have to use the microsoft-never-gets-it-right macro */
1510 array_free (rfeed, EMPTY);
1457 array_free (fdchange, EMPTY); 1511 array_free (fdchange, EMPTY);
1458 array_free (timer, EMPTY); 1512 array_free (timer, EMPTY);
1459#if EV_PERIODIC_ENABLE 1513#if EV_PERIODIC_ENABLE
1460 array_free (periodic, EMPTY); 1514 array_free (periodic, EMPTY);
1461#endif 1515#endif
1470 1524
1471 backend = 0; 1525 backend = 0;
1472} 1526}
1473 1527
1474#if EV_USE_INOTIFY 1528#if EV_USE_INOTIFY
1475void inline_size infy_fork (EV_P); 1529inline_size void infy_fork (EV_P);
1476#endif 1530#endif
1477 1531
1478void inline_size 1532inline_size void
1479loop_fork (EV_P) 1533loop_fork (EV_P)
1480{ 1534{
1481#if EV_USE_PORT 1535#if EV_USE_PORT
1482 if (backend == EVBACKEND_PORT ) port_fork (EV_A); 1536 if (backend == EVBACKEND_PORT ) port_fork (EV_A);
1483#endif 1537#endif
1489#endif 1543#endif
1490#if EV_USE_INOTIFY 1544#if EV_USE_INOTIFY
1491 infy_fork (EV_A); 1545 infy_fork (EV_A);
1492#endif 1546#endif
1493 1547
1494 if (ev_is_active (&pipeev)) 1548 if (ev_is_active (&pipe_w))
1495 { 1549 {
1496 /* this "locks" the handlers against writing to the pipe */ 1550 /* this "locks" the handlers against writing to the pipe */
1497 /* while we modify the fd vars */ 1551 /* while we modify the fd vars */
1498 gotsig = 1; 1552 gotsig = 1;
1499#if EV_ASYNC_ENABLE 1553#if EV_ASYNC_ENABLE
1500 gotasync = 1; 1554 gotasync = 1;
1501#endif 1555#endif
1502 1556
1503 ev_ref (EV_A); 1557 ev_ref (EV_A);
1504 ev_io_stop (EV_A_ &pipeev); 1558 ev_io_stop (EV_A_ &pipe_w);
1505 1559
1506#if EV_USE_EVENTFD 1560#if EV_USE_EVENTFD
1507 if (evfd >= 0) 1561 if (evfd >= 0)
1508 close (evfd); 1562 close (evfd);
1509#endif 1563#endif
1514 close (evpipe [1]); 1568 close (evpipe [1]);
1515 } 1569 }
1516 1570
1517 evpipe_init (EV_A); 1571 evpipe_init (EV_A);
1518 /* now iterate over everything, in case we missed something */ 1572 /* now iterate over everything, in case we missed something */
1519 pipecb (EV_A_ &pipeev, EV_READ); 1573 pipecb (EV_A_ &pipe_w, EV_READ);
1520 } 1574 }
1521 1575
1522 postfork = 0; 1576 postfork = 0;
1523} 1577}
1524 1578
1720ev_invoke (EV_P_ void *w, int revents) 1774ev_invoke (EV_P_ void *w, int revents)
1721{ 1775{
1722 EV_CB_INVOKE ((W)w, revents); 1776 EV_CB_INVOKE ((W)w, revents);
1723} 1777}
1724 1778
1725void inline_speed 1779inline_speed void
1726call_pending (EV_P) 1780call_pending (EV_P)
1727{ 1781{
1728 int pri; 1782 int pri;
1729 1783
1730 for (pri = NUMPRI; pri--; ) 1784 for (pri = NUMPRI; pri--; )
1731 while (pendingcnt [pri]) 1785 while (pendingcnt [pri])
1732 { 1786 {
1733 ANPENDING *p = pendings [pri] + --pendingcnt [pri]; 1787 ANPENDING *p = pendings [pri] + --pendingcnt [pri];
1734 1788
1735 if (expect_true (p->w))
1736 {
1737 /*assert (("libev: non-pending watcher on pending list", p->w->pending));*/ 1789 /*assert (("libev: non-pending watcher on pending list", p->w->pending));*/
1790 /* ^ this is no longer true, as pending_w could be here */
1738 1791
1739 p->w->pending = 0; 1792 p->w->pending = 0;
1740 EV_CB_INVOKE (p->w, p->events); 1793 EV_CB_INVOKE (p->w, p->events);
1741 EV_FREQUENT_CHECK; 1794 EV_FREQUENT_CHECK;
1742 }
1743 } 1795 }
1744} 1796}
1745 1797
1746#if EV_IDLE_ENABLE 1798#if EV_IDLE_ENABLE
1747void inline_size 1799/* make idle watchers pending. this handles the "call-idle */
1800/* only when higher priorities are idle" logic */
1801inline_size void
1748idle_reify (EV_P) 1802idle_reify (EV_P)
1749{ 1803{
1750 if (expect_false (idleall)) 1804 if (expect_false (idleall))
1751 { 1805 {
1752 int pri; 1806 int pri;
1764 } 1818 }
1765 } 1819 }
1766} 1820}
1767#endif 1821#endif
1768 1822
1769void inline_size 1823/* make timers pending */
1824inline_size void
1770timers_reify (EV_P) 1825timers_reify (EV_P)
1771{ 1826{
1772 EV_FREQUENT_CHECK; 1827 EV_FREQUENT_CHECK;
1773 1828
1774 while (timercnt && ANHE_at (timers [HEAP0]) < mn_now) 1829 if (timercnt && ANHE_at (timers [HEAP0]) < mn_now)
1775 { 1830 {
1776 ev_timer *w = (ev_timer *)ANHE_w (timers [HEAP0]); 1831 do
1777
1778 /*assert (("libev: inactive timer on timer heap detected", ev_is_active (w)));*/
1779
1780 /* first reschedule or stop timer */
1781 if (w->repeat)
1782 { 1832 {
1833 ev_timer *w = (ev_timer *)ANHE_w (timers [HEAP0]);
1834
1835 /*assert (("libev: inactive timer on timer heap detected", ev_is_active (w)));*/
1836
1837 /* first reschedule or stop timer */
1838 if (w->repeat)
1839 {
1783 ev_at (w) += w->repeat; 1840 ev_at (w) += w->repeat;
1784 if (ev_at (w) < mn_now) 1841 if (ev_at (w) < mn_now)
1785 ev_at (w) = mn_now; 1842 ev_at (w) = mn_now;
1786 1843
1787 assert (("libev: negative ev_timer repeat value found while processing timers", w->repeat > 0.)); 1844 assert (("libev: negative ev_timer repeat value found while processing timers", w->repeat > 0.));
1788 1845
1789 ANHE_at_cache (timers [HEAP0]); 1846 ANHE_at_cache (timers [HEAP0]);
1790 downheap (timers, timercnt, HEAP0); 1847 downheap (timers, timercnt, HEAP0);
1848 }
1849 else
1850 ev_timer_stop (EV_A_ w); /* nonrepeating: stop timer */
1851
1852 EV_FREQUENT_CHECK;
1853 feed_reverse (EV_A_ (W)w);
1791 } 1854 }
1792 else 1855 while (timercnt && ANHE_at (timers [HEAP0]) < mn_now);
1793 ev_timer_stop (EV_A_ w); /* nonrepeating: stop timer */
1794 1856
1795 EV_FREQUENT_CHECK;
1796 ev_feed_event (EV_A_ (W)w, EV_TIMEOUT); 1857 feed_reverse_done (EV_A_ EV_TIMEOUT);
1797 } 1858 }
1798} 1859}
1799 1860
1800#if EV_PERIODIC_ENABLE 1861#if EV_PERIODIC_ENABLE
1801void inline_size 1862/* make periodics pending */
1863inline_size void
1802periodics_reify (EV_P) 1864periodics_reify (EV_P)
1803{ 1865{
1804 EV_FREQUENT_CHECK; 1866 EV_FREQUENT_CHECK;
1805 1867
1806 while (periodiccnt && ANHE_at (periodics [HEAP0]) < ev_rt_now) 1868 while (periodiccnt && ANHE_at (periodics [HEAP0]) < ev_rt_now)
1807 { 1869 {
1808 ev_periodic *w = (ev_periodic *)ANHE_w (periodics [HEAP0]); 1870 int feed_count = 0;
1809 1871
1810 /*assert (("libev: inactive timer on periodic heap detected", ev_is_active (w)));*/ 1872 do
1811
1812 /* first reschedule or stop timer */
1813 if (w->reschedule_cb)
1814 { 1873 {
1874 ev_periodic *w = (ev_periodic *)ANHE_w (periodics [HEAP0]);
1875
1876 /*assert (("libev: inactive timer on periodic heap detected", ev_is_active (w)));*/
1877
1878 /* first reschedule or stop timer */
1879 if (w->reschedule_cb)
1880 {
1815 ev_at (w) = w->reschedule_cb (w, ev_rt_now); 1881 ev_at (w) = w->reschedule_cb (w, ev_rt_now);
1816 1882
1817 assert (("libev: ev_periodic reschedule callback returned time in the past", ev_at (w) >= ev_rt_now)); 1883 assert (("libev: ev_periodic reschedule callback returned time in the past", ev_at (w) >= ev_rt_now));
1818 1884
1819 ANHE_at_cache (periodics [HEAP0]); 1885 ANHE_at_cache (periodics [HEAP0]);
1820 downheap (periodics, periodiccnt, HEAP0); 1886 downheap (periodics, periodiccnt, HEAP0);
1887 }
1888 else if (w->interval)
1889 {
1890 ev_at (w) = w->offset + ceil ((ev_rt_now - w->offset) / w->interval) * w->interval;
1891 /* if next trigger time is not sufficiently in the future, put it there */
1892 /* this might happen because of floating point inexactness */
1893 if (ev_at (w) - ev_rt_now < TIME_EPSILON)
1894 {
1895 ev_at (w) += w->interval;
1896
1897 /* if interval is unreasonably low we might still have a time in the past */
1898 /* so correct this. this will make the periodic very inexact, but the user */
1899 /* has effectively asked to get triggered more often than possible */
1900 if (ev_at (w) < ev_rt_now)
1901 ev_at (w) = ev_rt_now;
1902 }
1903
1904 ANHE_at_cache (periodics [HEAP0]);
1905 downheap (periodics, periodiccnt, HEAP0);
1906 }
1907 else
1908 ev_periodic_stop (EV_A_ w); /* nonrepeating: stop timer */
1909
1910 EV_FREQUENT_CHECK;
1911 feed_reverse (EV_A_ (W)w);
1821 } 1912 }
1822 else if (w->interval) 1913 while (periodiccnt && ANHE_at (periodics [HEAP0]) < ev_rt_now);
1823 {
1824 ev_at (w) = w->offset + ceil ((ev_rt_now - w->offset) / w->interval) * w->interval;
1825 /* if next trigger time is not sufficiently in the future, put it there */
1826 /* this might happen because of floating point inexactness */
1827 if (ev_at (w) - ev_rt_now < TIME_EPSILON)
1828 {
1829 ev_at (w) += w->interval;
1830 1914
1831 /* if interval is unreasonably low we might still have a time in the past */
1832 /* so correct this. this will make the periodic very inexact, but the user */
1833 /* has effectively asked to get triggered more often than possible */
1834 if (ev_at (w) < ev_rt_now)
1835 ev_at (w) = ev_rt_now;
1836 }
1837
1838 ANHE_at_cache (periodics [HEAP0]);
1839 downheap (periodics, periodiccnt, HEAP0);
1840 }
1841 else
1842 ev_periodic_stop (EV_A_ w); /* nonrepeating: stop timer */
1843
1844 EV_FREQUENT_CHECK;
1845 ev_feed_event (EV_A_ (W)w, EV_PERIODIC); 1915 feed_reverse_done (EV_A_ EV_PERIODIC);
1846 } 1916 }
1847} 1917}
1848 1918
1919/* simply recalculate all periodics */
1920/* TODO: maybe ensure that at leats one event happens when jumping forward? */
1849static void noinline 1921static void noinline
1850periodics_reschedule (EV_P) 1922periodics_reschedule (EV_P)
1851{ 1923{
1852 int i; 1924 int i;
1853 1925
1866 1938
1867 reheap (periodics, periodiccnt); 1939 reheap (periodics, periodiccnt);
1868} 1940}
1869#endif 1941#endif
1870 1942
1871void inline_speed 1943/* adjust all timers by a given offset */
1944static void noinline
1945timers_reschedule (EV_P_ ev_tstamp adjust)
1946{
1947 int i;
1948
1949 for (i = 0; i < timercnt; ++i)
1950 {
1951 ANHE *he = timers + i + HEAP0;
1952 ANHE_w (*he)->at += adjust;
1953 ANHE_at_cache (*he);
1954 }
1955}
1956
1957/* fetch new monotonic and realtime times from the kernel */
1958/* also detetc if there was a timejump, and act accordingly */
1959inline_speed void
1872time_update (EV_P_ ev_tstamp max_block) 1960time_update (EV_P_ ev_tstamp max_block)
1873{ 1961{
1874 int i;
1875
1876#if EV_USE_MONOTONIC 1962#if EV_USE_MONOTONIC
1877 if (expect_true (have_monotonic)) 1963 if (expect_true (have_monotonic))
1878 { 1964 {
1965 int i;
1879 ev_tstamp odiff = rtmn_diff; 1966 ev_tstamp odiff = rtmn_diff;
1880 1967
1881 mn_now = get_clock (); 1968 mn_now = get_clock ();
1882 1969
1883 /* only fetch the realtime clock every 0.5*MIN_TIMEJUMP seconds */ 1970 /* only fetch the realtime clock every 0.5*MIN_TIMEJUMP seconds */
1909 ev_rt_now = ev_time (); 1996 ev_rt_now = ev_time ();
1910 mn_now = get_clock (); 1997 mn_now = get_clock ();
1911 now_floor = mn_now; 1998 now_floor = mn_now;
1912 } 1999 }
1913 2000
2001 /* no timer adjustment, as the monotonic clock doesn't jump */
2002 /* timers_reschedule (EV_A_ rtmn_diff - odiff) */
1914# if EV_PERIODIC_ENABLE 2003# if EV_PERIODIC_ENABLE
1915 periodics_reschedule (EV_A); 2004 periodics_reschedule (EV_A);
1916# endif 2005# endif
1917 /* no timer adjustment, as the monotonic clock doesn't jump */
1918 /* timers_reschedule (EV_A_ rtmn_diff - odiff) */
1919 } 2006 }
1920 else 2007 else
1921#endif 2008#endif
1922 { 2009 {
1923 ev_rt_now = ev_time (); 2010 ev_rt_now = ev_time ();
1924 2011
1925 if (expect_false (mn_now > ev_rt_now || ev_rt_now > mn_now + max_block + MIN_TIMEJUMP)) 2012 if (expect_false (mn_now > ev_rt_now || ev_rt_now > mn_now + max_block + MIN_TIMEJUMP))
1926 { 2013 {
2014 /* adjust timers. this is easy, as the offset is the same for all of them */
2015 timers_reschedule (EV_A_ ev_rt_now - mn_now);
1927#if EV_PERIODIC_ENABLE 2016#if EV_PERIODIC_ENABLE
1928 periodics_reschedule (EV_A); 2017 periodics_reschedule (EV_A);
1929#endif 2018#endif
1930 /* adjust timers. this is easy, as the offset is the same for all of them */
1931 for (i = 0; i < timercnt; ++i)
1932 {
1933 ANHE *he = timers + i + HEAP0;
1934 ANHE_w (*he)->at += ev_rt_now - mn_now;
1935 ANHE_at_cache (*he);
1936 }
1937 } 2019 }
1938 2020
1939 mn_now = ev_rt_now; 2021 mn_now = ev_rt_now;
1940 } 2022 }
1941}
1942
1943void
1944ev_ref (EV_P)
1945{
1946 ++activecnt;
1947}
1948
1949void
1950ev_unref (EV_P)
1951{
1952 --activecnt;
1953}
1954
1955void
1956ev_now_update (EV_P)
1957{
1958 time_update (EV_A_ 1e100);
1959} 2023}
1960 2024
1961static int loop_done; 2025static int loop_done;
1962 2026
1963void 2027void
1997 { 2061 {
1998 queue_events (EV_A_ (W *)prepares, preparecnt, EV_PREPARE); 2062 queue_events (EV_A_ (W *)prepares, preparecnt, EV_PREPARE);
1999 call_pending (EV_A); 2063 call_pending (EV_A);
2000 } 2064 }
2001 2065
2002 if (expect_false (!activecnt))
2003 break;
2004
2005 /* we might have forked, so reify kernel state if necessary */ 2066 /* we might have forked, so reify kernel state if necessary */
2006 if (expect_false (postfork)) 2067 if (expect_false (postfork))
2007 loop_fork (EV_A); 2068 loop_fork (EV_A);
2008 2069
2009 /* update fd-related kernel structures */ 2070 /* update fd-related kernel structures */
2014 ev_tstamp waittime = 0.; 2075 ev_tstamp waittime = 0.;
2015 ev_tstamp sleeptime = 0.; 2076 ev_tstamp sleeptime = 0.;
2016 2077
2017 if (expect_true (!(flags & EVLOOP_NONBLOCK || idleall || !activecnt))) 2078 if (expect_true (!(flags & EVLOOP_NONBLOCK || idleall || !activecnt)))
2018 { 2079 {
2080 /* remember old timestamp for io_blocktime calculation */
2081 ev_tstamp prev_mn_now = mn_now;
2082
2019 /* update time to cancel out callback processing overhead */ 2083 /* update time to cancel out callback processing overhead */
2020 time_update (EV_A_ 1e100); 2084 time_update (EV_A_ 1e100);
2021 2085
2022 waittime = MAX_BLOCKTIME; 2086 waittime = MAX_BLOCKTIME;
2023 2087
2033 ev_tstamp to = ANHE_at (periodics [HEAP0]) - ev_rt_now + backend_fudge; 2097 ev_tstamp to = ANHE_at (periodics [HEAP0]) - ev_rt_now + backend_fudge;
2034 if (waittime > to) waittime = to; 2098 if (waittime > to) waittime = to;
2035 } 2099 }
2036#endif 2100#endif
2037 2101
2102 /* don't let timeouts decrease the waittime below timeout_blocktime */
2038 if (expect_false (waittime < timeout_blocktime)) 2103 if (expect_false (waittime < timeout_blocktime))
2039 waittime = timeout_blocktime; 2104 waittime = timeout_blocktime;
2040 2105
2041 sleeptime = waittime - backend_fudge; 2106 /* extra check because io_blocktime is commonly 0 */
2042
2043 if (expect_true (sleeptime > io_blocktime)) 2107 if (expect_false (io_blocktime))
2044 sleeptime = io_blocktime;
2045
2046 if (sleeptime)
2047 { 2108 {
2109 sleeptime = io_blocktime - (mn_now - prev_mn_now);
2110
2111 if (sleeptime > waittime - backend_fudge)
2112 sleeptime = waittime - backend_fudge;
2113
2114 if (expect_true (sleeptime > 0.))
2115 {
2048 ev_sleep (sleeptime); 2116 ev_sleep (sleeptime);
2049 waittime -= sleeptime; 2117 waittime -= sleeptime;
2118 }
2050 } 2119 }
2051 } 2120 }
2052 2121
2053 ++loop_count; 2122 ++loop_count;
2054 backend_poll (EV_A_ waittime); 2123 backend_poll (EV_A_ waittime);
2088ev_unloop (EV_P_ int how) 2157ev_unloop (EV_P_ int how)
2089{ 2158{
2090 loop_done = how; 2159 loop_done = how;
2091} 2160}
2092 2161
2162void
2163ev_ref (EV_P)
2164{
2165 ++activecnt;
2166}
2167
2168void
2169ev_unref (EV_P)
2170{
2171 --activecnt;
2172}
2173
2174void
2175ev_now_update (EV_P)
2176{
2177 time_update (EV_A_ 1e100);
2178}
2179
2180void
2181ev_suspend (EV_P)
2182{
2183 ev_now_update (EV_A);
2184}
2185
2186void
2187ev_resume (EV_P)
2188{
2189 ev_tstamp mn_prev = mn_now;
2190
2191 ev_now_update (EV_A);
2192 timers_reschedule (EV_A_ mn_now - mn_prev);
2193#if EV_PERIODIC_ENABLE
2194 /* TODO: really do this? */
2195 periodics_reschedule (EV_A);
2196#endif
2197}
2198
2093/*****************************************************************************/ 2199/*****************************************************************************/
2200/* singly-linked list management, used when the expected list length is short */
2094 2201
2095void inline_size 2202inline_size void
2096wlist_add (WL *head, WL elem) 2203wlist_add (WL *head, WL elem)
2097{ 2204{
2098 elem->next = *head; 2205 elem->next = *head;
2099 *head = elem; 2206 *head = elem;
2100} 2207}
2101 2208
2102void inline_size 2209inline_size void
2103wlist_del (WL *head, WL elem) 2210wlist_del (WL *head, WL elem)
2104{ 2211{
2105 while (*head) 2212 while (*head)
2106 { 2213 {
2107 if (*head == elem) 2214 if (*head == elem)
2112 2219
2113 head = &(*head)->next; 2220 head = &(*head)->next;
2114 } 2221 }
2115} 2222}
2116 2223
2117void inline_speed 2224/* internal, faster, version of ev_clear_pending */
2225inline_speed void
2118clear_pending (EV_P_ W w) 2226clear_pending (EV_P_ W w)
2119{ 2227{
2120 if (w->pending) 2228 if (w->pending)
2121 { 2229 {
2122 pendings [ABSPRI (w)][w->pending - 1].w = 0; 2230 pendings [ABSPRI (w)][w->pending - 1].w = (W)&pending_w;
2123 w->pending = 0; 2231 w->pending = 0;
2124 } 2232 }
2125} 2233}
2126 2234
2127int 2235int
2131 int pending = w_->pending; 2239 int pending = w_->pending;
2132 2240
2133 if (expect_true (pending)) 2241 if (expect_true (pending))
2134 { 2242 {
2135 ANPENDING *p = pendings [ABSPRI (w_)] + pending - 1; 2243 ANPENDING *p = pendings [ABSPRI (w_)] + pending - 1;
2244 p->w = (W)&pending_w;
2136 w_->pending = 0; 2245 w_->pending = 0;
2137 p->w = 0;
2138 return p->events; 2246 return p->events;
2139 } 2247 }
2140 else 2248 else
2141 return 0; 2249 return 0;
2142} 2250}
2143 2251
2144void inline_size 2252inline_size void
2145pri_adjust (EV_P_ W w) 2253pri_adjust (EV_P_ W w)
2146{ 2254{
2147 int pri = w->priority; 2255 int pri = w->priority;
2148 pri = pri < EV_MINPRI ? EV_MINPRI : pri; 2256 pri = pri < EV_MINPRI ? EV_MINPRI : pri;
2149 pri = pri > EV_MAXPRI ? EV_MAXPRI : pri; 2257 pri = pri > EV_MAXPRI ? EV_MAXPRI : pri;
2150 w->priority = pri; 2258 w->priority = pri;
2151} 2259}
2152 2260
2153void inline_speed 2261inline_speed void
2154ev_start (EV_P_ W w, int active) 2262ev_start (EV_P_ W w, int active)
2155{ 2263{
2156 pri_adjust (EV_A_ w); 2264 pri_adjust (EV_A_ w);
2157 w->active = active; 2265 w->active = active;
2158 ev_ref (EV_A); 2266 ev_ref (EV_A);
2159} 2267}
2160 2268
2161void inline_size 2269inline_size void
2162ev_stop (EV_P_ W w) 2270ev_stop (EV_P_ W w)
2163{ 2271{
2164 ev_unref (EV_A); 2272 ev_unref (EV_A);
2165 w->active = 0; 2273 w->active = 0;
2166} 2274}
2591 2699
2592 for (ofs = 0; ofs < len; ofs += sizeof (struct inotify_event) + ev->len) 2700 for (ofs = 0; ofs < len; ofs += sizeof (struct inotify_event) + ev->len)
2593 infy_wd (EV_A_ ev->wd, ev->wd, ev); 2701 infy_wd (EV_A_ ev->wd, ev->wd, ev);
2594} 2702}
2595 2703
2596void inline_size 2704inline_size void
2597check_2625 (EV_P) 2705check_2625 (EV_P)
2598{ 2706{
2599 /* kernels < 2.6.25 are borked 2707 /* kernels < 2.6.25 are borked
2600 * http://www.ussg.indiana.edu/hypermail/linux/kernel/0711.3/1208.html 2708 * http://www.ussg.indiana.edu/hypermail/linux/kernel/0711.3/1208.html
2601 */ 2709 */
2614 return; 2722 return;
2615 2723
2616 fs_2625 = 1; 2724 fs_2625 = 1;
2617} 2725}
2618 2726
2619void inline_size 2727inline_size void
2620infy_init (EV_P) 2728infy_init (EV_P)
2621{ 2729{
2622 if (fs_fd != -2) 2730 if (fs_fd != -2)
2623 return; 2731 return;
2624 2732
2634 ev_set_priority (&fs_w, EV_MAXPRI); 2742 ev_set_priority (&fs_w, EV_MAXPRI);
2635 ev_io_start (EV_A_ &fs_w); 2743 ev_io_start (EV_A_ &fs_w);
2636 } 2744 }
2637} 2745}
2638 2746
2639void inline_size 2747inline_size void
2640infy_fork (EV_P) 2748infy_fork (EV_P)
2641{ 2749{
2642 int slot; 2750 int slot;
2643 2751
2644 if (fs_fd < 0) 2752 if (fs_fd < 0)
3148 } 3256 }
3149} 3257}
3150 3258
3151/*****************************************************************************/ 3259/*****************************************************************************/
3152 3260
3153#if 0 3261#if EV_WALK_ENABLE
3154void 3262void
3155ev_walk (EV_P_ int types, void (*cb)(EV_P_ int type, void *w)) 3263ev_walk (EV_P_ int types, void (*cb)(EV_P_ int type, void *w))
3156{ 3264{
3157 int i, j; 3265 int i, j;
3158 ev_watcher_list *wl, *wn; 3266 ev_watcher_list *wl, *wn;
3174#if EV_USE_INOTIFY 3282#if EV_USE_INOTIFY
3175 if (ev_cb ((ev_io *)wl) == infy_cb) 3283 if (ev_cb ((ev_io *)wl) == infy_cb)
3176 ; 3284 ;
3177 else 3285 else
3178#endif 3286#endif
3179 if ((ev_io *)wl != &pipeev) 3287 if ((ev_io *)wl != &pipe_w)
3180 if (types & EV_IO) 3288 if (types & EV_IO)
3181 cb (EV_A_ EV_IO, wl); 3289 cb (EV_A_ EV_IO, wl);
3182 3290
3183 wl = wn; 3291 wl = wn;
3184 } 3292 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines