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

Comparing libev/ev.c (file contents):
Revision 1.306 by root, Sun Jul 19 06:35:25 2009 UTC vs.
Revision 1.317 by root, Sat Nov 14 00:15:21 2009 UTC

187#endif 187#endif
188 188
189/* this block tries to deduce configuration from header-defined symbols and defaults */ 189/* this block tries to deduce configuration from header-defined symbols and defaults */
190 190
191/* try to deduce the maximum number of signals on this platform */ 191/* try to deduce the maximum number of signals on this platform */
192/* one some platforms, NSIG is one too large. we do not bother */
193#if defined (EV_NSIG) 192#if defined (EV_NSIG)
194/* use what's provided */ 193/* use what's provided */
195#elif defined (NSIG) 194#elif defined (NSIG)
196# define EV_NSIG (NSIG) 195# define EV_NSIG (NSIG)
197#elif defined(_NSIG) 196#elif defined(_NSIG)
303# define EV_USE_EVENTFD 0 302# define EV_USE_EVENTFD 0
304# endif 303# endif
305#endif 304#endif
306 305
307#ifndef EV_USE_SIGNALFD 306#ifndef EV_USE_SIGNALFD
308# if __linux && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 9)) 307# if __linux && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 7))
309# define EV_USE_SIGNALFD 1 308# define EV_USE_SIGNALFD 1
310# else 309# else
311# define EV_USE_SIGNALFD 0 310# define EV_USE_SIGNALFD 0
312# endif 311# endif
313#endif 312#endif
387# include <stdint.h> 386# include <stdint.h>
388# ifndef EFD_NONBLOCK 387# ifndef EFD_NONBLOCK
389# define EFD_NONBLOCK O_NONBLOCK 388# define EFD_NONBLOCK O_NONBLOCK
390# endif 389# endif
391# ifndef EFD_CLOEXEC 390# ifndef EFD_CLOEXEC
391# ifdef O_CLOEXEC
392# define EFD_CLOEXEC O_CLOEXEC 392# define EFD_CLOEXEC O_CLOEXEC
393# else
394# define EFD_CLOEXEC 02000000
395# endif
393# endif 396# endif
394# ifdef __cplusplus 397# ifdef __cplusplus
395extern "C" { 398extern "C" {
396# endif 399# endif
397int eventfd (unsigned int initval, int flags); 400int eventfd (unsigned int initval, int flags);
399} 402}
400# endif 403# endif
401#endif 404#endif
402 405
403#if EV_USE_SIGNALFD 406#if EV_USE_SIGNALFD
404# include <sys/signalfd.h> 407/* our minimum requirement is glibc 2.7 which has the stub, but not the header */
408# include <stdint.h>
409# ifndef SFD_NONBLOCK
410# define SFD_NONBLOCK O_NONBLOCK
405#endif 411# endif
412# ifndef SFD_CLOEXEC
413# ifdef O_CLOEXEC
414# define SFD_CLOEXEC O_CLOEXEC
415# else
416# define SFD_CLOEXEC 02000000
417# endif
418# endif
419# ifdef __cplusplus
420extern "C" {
421# endif
422int signalfd (int fd, const sigset_t *mask, int flags);
423
424struct signalfd_siginfo
425{
426 uint32_t ssi_signo;
427 char pad[128 - sizeof (uint32_t)];
428};
429# ifdef __cplusplus
430}
431# endif
432#endif
433
406 434
407/**/ 435/**/
408 436
409#if EV_VERIFY >= 3 437#if EV_VERIFY >= 3
410# define EV_FREQUENT_CHECK ev_loop_verify (EV_A) 438# define EV_FREQUENT_CHECK ev_loop_verify (EV_A)
422 */ 450 */
423#define TIME_EPSILON 0.0001220703125 /* 1/8192 */ 451#define TIME_EPSILON 0.0001220703125 /* 1/8192 */
424 452
425#define MIN_TIMEJUMP 1. /* minimum timejump that gets detected (if monotonic clock available) */ 453#define MIN_TIMEJUMP 1. /* minimum timejump that gets detected (if monotonic clock available) */
426#define MAX_BLOCKTIME 59.743 /* never wait longer than this time (to detect time jumps) */ 454#define MAX_BLOCKTIME 59.743 /* never wait longer than this time (to detect time jumps) */
427/*#define CLEANUP_INTERVAL (MAX_BLOCKTIME * 5.) /* how often to try to free memory and re-check fds, TODO */
428 455
429#if __GNUC__ >= 4 456#if __GNUC__ >= 4
430# define expect(expr,value) __builtin_expect ((expr),(value)) 457# define expect(expr,value) __builtin_expect ((expr),(value))
431# define noinline __attribute__ ((noinline)) 458# define noinline __attribute__ ((noinline))
432#else 459#else
471static EV_ATOMIC_T have_realtime; /* did clock_gettime (CLOCK_REALTIME) work? */ 498static EV_ATOMIC_T have_realtime; /* did clock_gettime (CLOCK_REALTIME) work? */
472#endif 499#endif
473 500
474#if EV_USE_MONOTONIC 501#if EV_USE_MONOTONIC
475static EV_ATOMIC_T have_monotonic; /* did clock_gettime (CLOCK_MONOTONIC) work? */ 502static EV_ATOMIC_T have_monotonic; /* did clock_gettime (CLOCK_MONOTONIC) work? */
503#endif
504
505#ifndef EV_FD_TO_WIN32_HANDLE
506# define EV_FD_TO_WIN32_HANDLE(fd) _get_osfhandle (fd)
507#endif
508#ifndef EV_WIN32_HANDLE_TO_FD
509# define EV_WIN32_HANDLE_TO_FD(handle) _open_osfhandle (fd, 0)
510#endif
511#ifndef EV_WIN32_CLOSE_FD
512# define EV_WIN32_CLOSE_FD(fd) close (fd)
476#endif 513#endif
477 514
478#ifdef _WIN32 515#ifdef _WIN32
479# include "ev_win32.c" 516# include "ev_win32.c"
480#endif 517#endif
873 910
874#if EV_SELECT_IS_WINSOCKET 911#if EV_SELECT_IS_WINSOCKET
875 if (events) 912 if (events)
876 { 913 {
877 unsigned long arg; 914 unsigned long arg;
878 #ifdef EV_FD_TO_WIN32_HANDLE
879 anfd->handle = EV_FD_TO_WIN32_HANDLE (fd); 915 anfd->handle = EV_FD_TO_WIN32_HANDLE (fd);
880 #else
881 anfd->handle = _get_osfhandle (fd);
882 #endif
883 assert (("libev: only socket fds supported in this configuration", ioctlsocket (anfd->handle, FIONREAD, &arg) == 0)); 916 assert (("libev: only socket fds supported in this configuration", ioctlsocket (anfd->handle, FIONREAD, &arg) == 0));
884 } 917 }
885#endif 918#endif
886 919
887 { 920 {
958 991
959 for (fd = anfdmax; fd--; ) 992 for (fd = anfdmax; fd--; )
960 if (anfds [fd].events) 993 if (anfds [fd].events)
961 { 994 {
962 fd_kill (EV_A_ fd); 995 fd_kill (EV_A_ fd);
963 return; 996 break;
964 } 997 }
965} 998}
966 999
967/* usually called after fork if backend needs to re-arm all fds from scratch */ 1000/* usually called after fork if backend needs to re-arm all fds from scratch */
968static void noinline 1001static void noinline
1058 1091
1059 for (;;) 1092 for (;;)
1060 { 1093 {
1061 int c = k << 1; 1094 int c = k << 1;
1062 1095
1063 if (c > N + HEAP0 - 1) 1096 if (c >= N + HEAP0)
1064 break; 1097 break;
1065 1098
1066 c += c + 1 < N + HEAP0 && ANHE_at (heap [c]) > ANHE_at (heap [c + 1]) 1099 c += c + 1 < N + HEAP0 && ANHE_at (heap [c]) > ANHE_at (heap [c + 1])
1067 ? 1 : 0; 1100 ? 1 : 0;
1068 1101
1104 1137
1105/* move an element suitably so it is in a correct place */ 1138/* move an element suitably so it is in a correct place */
1106inline_size void 1139inline_size void
1107adjustheap (ANHE *heap, int N, int k) 1140adjustheap (ANHE *heap, int N, int k)
1108{ 1141{
1109 if (k > HEAP0 && ANHE_at (heap [HPARENT (k)]) >= ANHE_at (heap [k])) 1142 if (k > HEAP0 && ANHE_at (heap [k]) <= ANHE_at (heap [HPARENT (k)]))
1110 upheap (heap, k); 1143 upheap (heap, k);
1111 else 1144 else
1112 downheap (heap, N, k); 1145 downheap (heap, N, k);
1113} 1146}
1114 1147
1127/*****************************************************************************/ 1160/*****************************************************************************/
1128 1161
1129/* associate signal watchers to a signal signal */ 1162/* associate signal watchers to a signal signal */
1130typedef struct 1163typedef struct
1131{ 1164{
1165 EV_ATOMIC_T pending;
1132#if EV_MULTIPLICITY 1166#if EV_MULTIPLICITY
1133 EV_P; 1167 EV_P;
1134#endif 1168#endif
1135 WL head; 1169 WL head;
1136 EV_ATOMIC_T gotsig;
1137} ANSIG; 1170} ANSIG;
1138 1171
1139static ANSIG signals [EV_NSIG - 1]; 1172static ANSIG signals [EV_NSIG - 1];
1140static EV_ATOMIC_T gotsig;
1141 1173
1142/*****************************************************************************/ 1174/*****************************************************************************/
1143 1175
1144/* used to prepare libev internal fd's */ 1176/* used to prepare libev internal fd's */
1145/* this is not fork-safe */ 1177/* this is not fork-safe */
1213/* called whenever the libev signal pipe */ 1245/* called whenever the libev signal pipe */
1214/* got some events (signal, async) */ 1246/* got some events (signal, async) */
1215static void 1247static void
1216pipecb (EV_P_ ev_io *iow, int revents) 1248pipecb (EV_P_ ev_io *iow, int revents)
1217{ 1249{
1250 int i;
1251
1218#if EV_USE_EVENTFD 1252#if EV_USE_EVENTFD
1219 if (evfd >= 0) 1253 if (evfd >= 0)
1220 { 1254 {
1221 uint64_t counter; 1255 uint64_t counter;
1222 read (evfd, &counter, sizeof (uint64_t)); 1256 read (evfd, &counter, sizeof (uint64_t));
1226 { 1260 {
1227 char dummy; 1261 char dummy;
1228 read (evpipe [0], &dummy, 1); 1262 read (evpipe [0], &dummy, 1);
1229 } 1263 }
1230 1264
1231 if (gotsig && ev_is_default_loop (EV_A)) 1265 if (sig_pending)
1232 { 1266 {
1233 int signum; 1267 sig_pending = 0;
1234 gotsig = 0;
1235 1268
1236 for (signum = EV_NSIG - 1; signum--; ) 1269 for (i = EV_NSIG - 1; i--; )
1237 if (signals [signum].gotsig) 1270 if (expect_false (signals [i].pending))
1238 ev_feed_signal_event (EV_A_ signum + 1); 1271 ev_feed_signal_event (EV_A_ i + 1);
1239 } 1272 }
1240 1273
1241#if EV_ASYNC_ENABLE 1274#if EV_ASYNC_ENABLE
1242 if (gotasync) 1275 if (async_pending)
1243 { 1276 {
1244 int i; 1277 async_pending = 0;
1245 gotasync = 0;
1246 1278
1247 for (i = asynccnt; i--; ) 1279 for (i = asynccnt; i--; )
1248 if (asyncs [i]->sent) 1280 if (asyncs [i]->sent)
1249 { 1281 {
1250 asyncs [i]->sent = 0; 1282 asyncs [i]->sent = 0;
1265 1297
1266#if _WIN32 1298#if _WIN32
1267 signal (signum, ev_sighandler); 1299 signal (signum, ev_sighandler);
1268#endif 1300#endif
1269 1301
1270 signals [signum - 1].gotsig = 1; 1302 signals [signum - 1].pending = 1;
1271 evpipe_write (EV_A_ &gotsig); 1303 evpipe_write (EV_A_ &sig_pending);
1272} 1304}
1273 1305
1274void noinline 1306void noinline
1275ev_feed_signal_event (EV_P_ int signum) 1307ev_feed_signal_event (EV_P_ int signum)
1276{ 1308{
1277 WL w; 1309 WL w;
1278 1310
1311 if (expect_false (signum <= 0 || signum > EV_NSIG))
1312 return;
1313
1314 --signum;
1315
1279#if EV_MULTIPLICITY 1316#if EV_MULTIPLICITY
1280 assert (("libev: feeding signal events is only supported in the default loop", loop == ev_default_loop_ptr)); 1317 /* it is permissible to try to feed a signal to the wrong loop */
1281#endif 1318 /* or, likely more useful, feeding a signal nobody is waiting for */
1282 1319
1283 if (signum <= 0 || signum > EV_NSIG) 1320 if (expect_false (signals [signum].loop != EV_A))
1284 return; 1321 return;
1322#endif
1285 1323
1286 --signum;
1287
1288 signals [signum].gotsig = 0; 1324 signals [signum].pending = 0;
1289 1325
1290 for (w = signals [signum].head; w; w = w->next) 1326 for (w = signals [signum].head; w; w = w->next)
1291 ev_feed_event (EV_A_ (W)w, EV_SIGNAL); 1327 ev_feed_event (EV_A_ (W)w, EV_SIGNAL);
1292} 1328}
1293 1329
1560 1596
1561 io_blocktime = 0.; 1597 io_blocktime = 0.;
1562 timeout_blocktime = 0.; 1598 timeout_blocktime = 0.;
1563 backend = 0; 1599 backend = 0;
1564 backend_fd = -1; 1600 backend_fd = -1;
1565 gotasync = 0; 1601 sig_pending = 0;
1602#if EV_ASYNC_ENABLE
1603 async_pending = 0;
1604#endif
1566#if EV_USE_INOTIFY 1605#if EV_USE_INOTIFY
1567 fs_fd = flags & EVFLAG_NOINOTIFY ? -1 : -2; 1606 fs_fd = flags & EVFLAG_NOINOTIFY ? -1 : -2;
1568#endif 1607#endif
1569#if EV_USE_SIGNALFD 1608#if EV_USE_SIGNALFD
1570 sigfd = flags & EVFLAG_NOSIGFD ? -1 : -2; 1609 sigfd = flags & EVFLAG_NOSIGFD ? -1 : -2;
1612 close (evfd); 1651 close (evfd);
1613#endif 1652#endif
1614 1653
1615 if (evpipe [0] >= 0) 1654 if (evpipe [0] >= 0)
1616 { 1655 {
1617 close (evpipe [0]); 1656 EV_WIN32_CLOSE_FD (evpipe [0]);
1618 close (evpipe [1]); 1657 EV_WIN32_CLOSE_FD (evpipe [1]);
1619 } 1658 }
1620 } 1659 }
1621 1660
1622#if EV_USE_SIGNALFD 1661#if EV_USE_SIGNALFD
1623 if (ev_is_active (&sigfd_w)) 1662 if (ev_is_active (&sigfd_w))
1624 {
1625 /*ev_ref (EV_A);*/
1626 /*ev_io_stop (EV_A_ &sigfd_w);*/
1627
1628 close (sigfd); 1663 close (sigfd);
1629 }
1630#endif 1664#endif
1631 1665
1632#if EV_USE_INOTIFY 1666#if EV_USE_INOTIFY
1633 if (fs_fd >= 0) 1667 if (fs_fd >= 0)
1634 close (fs_fd); 1668 close (fs_fd);
1704 1738
1705 if (ev_is_active (&pipe_w)) 1739 if (ev_is_active (&pipe_w))
1706 { 1740 {
1707 /* this "locks" the handlers against writing to the pipe */ 1741 /* this "locks" the handlers against writing to the pipe */
1708 /* while we modify the fd vars */ 1742 /* while we modify the fd vars */
1709 gotsig = 1; 1743 sig_pending = 1;
1710#if EV_ASYNC_ENABLE 1744#if EV_ASYNC_ENABLE
1711 gotasync = 1; 1745 async_pending = 1;
1712#endif 1746#endif
1713 1747
1714 ev_ref (EV_A); 1748 ev_ref (EV_A);
1715 ev_io_stop (EV_A_ &pipe_w); 1749 ev_io_stop (EV_A_ &pipe_w);
1716 1750
1719 close (evfd); 1753 close (evfd);
1720#endif 1754#endif
1721 1755
1722 if (evpipe [0] >= 0) 1756 if (evpipe [0] >= 0)
1723 { 1757 {
1724 close (evpipe [0]); 1758 EV_WIN32_CLOSE_FD (evpipe [0]);
1725 close (evpipe [1]); 1759 EV_WIN32_CLOSE_FD (evpipe [1]);
1726 } 1760 }
1727 1761
1728 evpipe_init (EV_A); 1762 evpipe_init (EV_A);
1729 /* now iterate over everything, in case we missed something */ 1763 /* now iterate over everything, in case we missed something */
1730 pipecb (EV_A_ &pipe_w, EV_READ); 1764 pipecb (EV_A_ &pipe_w, EV_READ);
1856 assert (checkmax >= checkcnt); 1890 assert (checkmax >= checkcnt);
1857 array_verify (EV_A_ (W *)checks, checkcnt); 1891 array_verify (EV_A_ (W *)checks, checkcnt);
1858 1892
1859# if 0 1893# if 0
1860 for (w = (ev_child *)childs [chain & (EV_PID_HASHSIZE - 1)]; w; w = (ev_child *)((WL)w)->next) 1894 for (w = (ev_child *)childs [chain & (EV_PID_HASHSIZE - 1)]; w; w = (ev_child *)((WL)w)->next)
1861 for (signum = EV_NSIG; signum--; ) if (signals [signum].gotsig) 1895 for (signum = EV_NSIG; signum--; ) if (signals [signum].pending)
1862# endif 1896# endif
1863#endif 1897#endif
1864} 1898}
1865#endif 1899#endif
1866 1900
2393inline_size void 2427inline_size void
2394wlist_del (WL *head, WL elem) 2428wlist_del (WL *head, WL elem)
2395{ 2429{
2396 while (*head) 2430 while (*head)
2397 { 2431 {
2398 if (*head == elem) 2432 if (expect_true (*head == elem))
2399 { 2433 {
2400 *head = elem->next; 2434 *head = elem->next;
2401 return; 2435 break;
2402 } 2436 }
2403 2437
2404 head = &(*head)->next; 2438 head = &(*head)->next;
2405 } 2439 }
2406} 2440}
2666 return; 2700 return;
2667 2701
2668 assert (("libev: ev_signal_start called with illegal signal number", w->signum > 0 && w->signum < EV_NSIG)); 2702 assert (("libev: ev_signal_start called with illegal signal number", w->signum > 0 && w->signum < EV_NSIG));
2669 2703
2670#if EV_MULTIPLICITY 2704#if EV_MULTIPLICITY
2671 assert (("libev: tried to attach to a signal from two different loops", 2705 assert (("libev: a signal must not be attached to two different loops",
2672 !signals [w->signum - 1].loop || signals [w->signum - 1].loop == loop)); 2706 !signals [w->signum - 1].loop || signals [w->signum - 1].loop == loop));
2673 2707
2674 signals [w->signum - 1].loop = EV_A; 2708 signals [w->signum - 1].loop = EV_A;
2675#endif 2709#endif
2676 2710
2713# if EV_USE_SIGNALFD 2747# if EV_USE_SIGNALFD
2714 if (sigfd < 0) /*TODO*/ 2748 if (sigfd < 0) /*TODO*/
2715# endif 2749# endif
2716 { 2750 {
2717# if _WIN32 2751# if _WIN32
2752 evpipe_init (EV_A);
2753
2718 signal (w->signum, ev_sighandler); 2754 signal (w->signum, ev_sighandler);
2719# else 2755# else
2720 struct sigaction sa; 2756 struct sigaction sa;
2721 2757
2722 evpipe_init (EV_A); 2758 evpipe_init (EV_A);
2747 wlist_del (&signals [w->signum - 1].head, (WL)w); 2783 wlist_del (&signals [w->signum - 1].head, (WL)w);
2748 ev_stop (EV_A_ (W)w); 2784 ev_stop (EV_A_ (W)w);
2749 2785
2750 if (!signals [w->signum - 1].head) 2786 if (!signals [w->signum - 1].head)
2751 { 2787 {
2752 #if EV_MULTIPLICITY 2788#if EV_MULTIPLICITY
2753 signals [w->signum - 1].loop = 0; /* unattach from signal */ 2789 signals [w->signum - 1].loop = 0; /* unattach from signal */
2754 #endif 2790#endif
2755 #if EV_USE_SIGNALFD 2791#if EV_USE_SIGNALFD
2756 if (sigfd >= 0) 2792 if (sigfd >= 0)
2757 { 2793 {
2758 sigprocmask (SIG_UNBLOCK, &sigfd_set, 0);//D 2794 sigprocmask (SIG_UNBLOCK, &sigfd_set, 0);//D
2759 sigdelset (&sigfd_set, w->signum); 2795 sigdelset (&sigfd_set, w->signum);
2760 signalfd (sigfd, &sigfd_set, 0); 2796 signalfd (sigfd, &sigfd_set, 0);
2761 sigprocmask (SIG_BLOCK, &sigfd_set, 0);//D 2797 sigprocmask (SIG_BLOCK, &sigfd_set, 0);//D
2762 /*TODO: maybe unblock signal? */ 2798 /*TODO: maybe unblock signal? */
2763 } 2799 }
2764 else 2800 else
2765 #endif 2801#endif
2766 signal (w->signum, SIG_DFL); 2802 signal (w->signum, SIG_DFL);
2767 } 2803 }
2768 2804
2769 EV_FREQUENT_CHECK; 2805 EV_FREQUENT_CHECK;
2770} 2806}
2852 } 2888 }
2853 } 2889 }
2854 2890
2855 if (w->wd >= 0) 2891 if (w->wd >= 0)
2856 { 2892 {
2893 struct statfs sfs;
2894
2857 wlist_add (&fs_hash [w->wd & (EV_INOTIFY_HASHSIZE - 1)].head, (WL)w); 2895 wlist_add (&fs_hash [w->wd & (EV_INOTIFY_HASHSIZE - 1)].head, (WL)w);
2858 2896
2859 /* now local changes will be tracked by inotify, but remote changes won't */ 2897 /* now local changes will be tracked by inotify, but remote changes won't */
2860 /* unless the filesystem it known to be local, we therefore still poll */ 2898 /* unless the filesystem is known to be local, we therefore still poll */
2861 /* also do poll on <2.6.25, but with normal frequency */ 2899 /* also do poll on <2.6.25, but with normal frequency */
2862 struct statfs sfs;
2863 2900
2864 if (fs_2625 && !statfs (w->path, &sfs)) 2901 if (fs_2625 && !statfs (w->path, &sfs))
2865 if (sfs.f_type == 0x1373 /* devfs */ 2902 if (sfs.f_type == 0x1373 /* devfs */
2866 || sfs.f_type == 0xEF53 /* ext2/3 */ 2903 || sfs.f_type == 0xEF53 /* ext2/3 */
2867 || sfs.f_type == 0x3153464a /* jfs */ 2904 || sfs.f_type == 0x3153464a /* jfs */
2956 return; 2993 return;
2957 2994
2958 fs_2625 = 1; 2995 fs_2625 = 1;
2959} 2996}
2960 2997
2998inline_size int
2999infy_newfd (void)
3000{
3001#if defined (IN_CLOEXEC) && defined (IN_NONBLOCK)
3002 int fd = inotify_init1 (IN_CLOEXEC | IN_NONBLOCK);
3003 if (fd >= 0)
3004 return fd;
3005#endif
3006 return inotify_init ();
3007}
3008
2961inline_size void 3009inline_size void
2962infy_init (EV_P) 3010infy_init (EV_P)
2963{ 3011{
2964 if (fs_fd != -2) 3012 if (fs_fd != -2)
2965 return; 3013 return;
2966 3014
2967 fs_fd = -1; 3015 fs_fd = -1;
2968 3016
2969 check_2625 (EV_A); 3017 check_2625 (EV_A);
2970 3018
2971 fs_fd = inotify_init (); 3019 fs_fd = infy_newfd ();
2972 3020
2973 if (fs_fd >= 0) 3021 if (fs_fd >= 0)
2974 { 3022 {
3023 fd_intern (fs_fd);
2975 ev_io_init (&fs_w, infy_cb, fs_fd, EV_READ); 3024 ev_io_init (&fs_w, infy_cb, fs_fd, EV_READ);
2976 ev_set_priority (&fs_w, EV_MAXPRI); 3025 ev_set_priority (&fs_w, EV_MAXPRI);
2977 ev_io_start (EV_A_ &fs_w); 3026 ev_io_start (EV_A_ &fs_w);
3027 ev_unref (EV_A);
2978 } 3028 }
2979} 3029}
2980 3030
2981inline_size void 3031inline_size void
2982infy_fork (EV_P) 3032infy_fork (EV_P)
2984 int slot; 3034 int slot;
2985 3035
2986 if (fs_fd < 0) 3036 if (fs_fd < 0)
2987 return; 3037 return;
2988 3038
3039 ev_ref (EV_A);
3040 ev_io_stop (EV_A_ &fs_w);
2989 close (fs_fd); 3041 close (fs_fd);
2990 fs_fd = inotify_init (); 3042 fs_fd = infy_newfd ();
3043
3044 if (fs_fd >= 0)
3045 {
3046 fd_intern (fs_fd);
3047 ev_io_set (&fs_w, fs_fd, EV_READ);
3048 ev_io_start (EV_A_ &fs_w);
3049 ev_unref (EV_A);
3050 }
2991 3051
2992 for (slot = 0; slot < EV_INOTIFY_HASHSIZE; ++slot) 3052 for (slot = 0; slot < EV_INOTIFY_HASHSIZE; ++slot)
2993 { 3053 {
2994 WL w_ = fs_hash [slot].head; 3054 WL w_ = fs_hash [slot].head;
2995 fs_hash [slot].head = 0; 3055 fs_hash [slot].head = 0;
3416 3476
3417void 3477void
3418ev_async_send (EV_P_ ev_async *w) 3478ev_async_send (EV_P_ ev_async *w)
3419{ 3479{
3420 w->sent = 1; 3480 w->sent = 1;
3421 evpipe_write (EV_A_ &gotasync); 3481 evpipe_write (EV_A_ &async_pending);
3422} 3482}
3423#endif 3483#endif
3424 3484
3425/*****************************************************************************/ 3485/*****************************************************************************/
3426 3486

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines