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

Comparing libev/ev.c (file contents):
Revision 1.303 by root, Sun Jul 19 01:36:34 2009 UTC vs.
Revision 1.311 by root, Wed Jul 29 09:36:05 2009 UTC

186# endif 186# endif
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 */
192#if defined (EV_NSIG)
193/* use what's provided */
194#elif defined (NSIG)
195# define EV_NSIG (NSIG)
196#elif defined(_NSIG)
197# define EV_NSIG (_NSIG)
198#elif defined (SIGMAX)
199# define EV_NSIG (SIGMAX+1)
200#elif defined (SIG_MAX)
201# define EV_NSIG (SIG_MAX+1)
202#elif defined (_SIG_MAX)
203# define EV_NSIG (_SIG_MAX+1)
204#elif defined (MAXSIG)
205# define EV_NSIG (MAXSIG+1)
206#elif defined (MAX_SIG)
207# define EV_NSIG (MAX_SIG+1)
208#elif defined (SIGARRAYSIZE)
209# define EV_NSIG SIGARRAYSIZE /* Assume ary[SIGARRAYSIZE] */
210#elif defined (_sys_nsig)
211# define EV_NSIG (_sys_nsig) /* Solaris 2.5 */
212#else
213# error "unable to find value for NSIG, please report"
214/* to make it compile regardless, just remove the above line */
215# define EV_NSIG 65
216#endif
217
191#ifndef EV_USE_CLOCK_SYSCALL 218#ifndef EV_USE_CLOCK_SYSCALL
192# if __linux && __GLIBC__ >= 2 219# if __linux && __GLIBC__ >= 2
193# define EV_USE_CLOCK_SYSCALL 1 220# define EV_USE_CLOCK_SYSCALL 1
194# else 221# else
195# define EV_USE_CLOCK_SYSCALL 0 222# define EV_USE_CLOCK_SYSCALL 0
359# include <stdint.h> 386# include <stdint.h>
360# ifndef EFD_NONBLOCK 387# ifndef EFD_NONBLOCK
361# define EFD_NONBLOCK O_NONBLOCK 388# define EFD_NONBLOCK O_NONBLOCK
362# endif 389# endif
363# ifndef EFD_CLOEXEC 390# ifndef EFD_CLOEXEC
391# ifdef O_CLOEXEC
364# define EFD_CLOEXEC O_CLOEXEC 392# define EFD_CLOEXEC O_CLOEXEC
393# else
394# define EFD_CLOEXEC 02000000
395# endif
365# endif 396# endif
366# ifdef __cplusplus 397# ifdef __cplusplus
367extern "C" { 398extern "C" {
368# endif 399# endif
369int eventfd (unsigned int initval, int flags); 400int eventfd (unsigned int initval, int flags);
930 961
931 for (fd = anfdmax; fd--; ) 962 for (fd = anfdmax; fd--; )
932 if (anfds [fd].events) 963 if (anfds [fd].events)
933 { 964 {
934 fd_kill (EV_A_ fd); 965 fd_kill (EV_A_ fd);
935 return; 966 break;
936 } 967 }
937} 968}
938 969
939/* usually called after fork if backend needs to re-arm all fds from scratch */ 970/* usually called after fork if backend needs to re-arm all fds from scratch */
940static void noinline 971static void noinline
1030 1061
1031 for (;;) 1062 for (;;)
1032 { 1063 {
1033 int c = k << 1; 1064 int c = k << 1;
1034 1065
1035 if (c > N + HEAP0 - 1) 1066 if (c >= N + HEAP0)
1036 break; 1067 break;
1037 1068
1038 c += c + 1 < N + HEAP0 && ANHE_at (heap [c]) > ANHE_at (heap [c + 1]) 1069 c += c + 1 < N + HEAP0 && ANHE_at (heap [c]) > ANHE_at (heap [c + 1])
1039 ? 1 : 0; 1070 ? 1 : 0;
1040 1071
1076 1107
1077/* move an element suitably so it is in a correct place */ 1108/* move an element suitably so it is in a correct place */
1078inline_size void 1109inline_size void
1079adjustheap (ANHE *heap, int N, int k) 1110adjustheap (ANHE *heap, int N, int k)
1080{ 1111{
1081 if (k > HEAP0 && ANHE_at (heap [HPARENT (k)]) >= ANHE_at (heap [k])) 1112 if (k > HEAP0 && ANHE_at (heap [k]) <= ANHE_at (heap [HPARENT (k)]))
1082 upheap (heap, k); 1113 upheap (heap, k);
1083 else 1114 else
1084 downheap (heap, N, k); 1115 downheap (heap, N, k);
1085} 1116}
1086 1117
1099/*****************************************************************************/ 1130/*****************************************************************************/
1100 1131
1101/* associate signal watchers to a signal signal */ 1132/* associate signal watchers to a signal signal */
1102typedef struct 1133typedef struct
1103{ 1134{
1135 EV_ATOMIC_T pending;
1136#if EV_MULTIPLICITY
1137 EV_P;
1138#endif
1104 WL head; 1139 WL head;
1105 EV_ATOMIC_T gotsig;
1106} ANSIG; 1140} ANSIG;
1107 1141
1108static ANSIG *signals; 1142static ANSIG signals [EV_NSIG - 1];
1109static int signalmax;
1110
1111static EV_ATOMIC_T gotsig;
1112 1143
1113/*****************************************************************************/ 1144/*****************************************************************************/
1114 1145
1115/* used to prepare libev internal fd's */ 1146/* used to prepare libev internal fd's */
1116/* this is not fork-safe */ 1147/* this is not fork-safe */
1184/* called whenever the libev signal pipe */ 1215/* called whenever the libev signal pipe */
1185/* got some events (signal, async) */ 1216/* got some events (signal, async) */
1186static void 1217static void
1187pipecb (EV_P_ ev_io *iow, int revents) 1218pipecb (EV_P_ ev_io *iow, int revents)
1188{ 1219{
1220 int i;
1221
1189#if EV_USE_EVENTFD 1222#if EV_USE_EVENTFD
1190 if (evfd >= 0) 1223 if (evfd >= 0)
1191 { 1224 {
1192 uint64_t counter; 1225 uint64_t counter;
1193 read (evfd, &counter, sizeof (uint64_t)); 1226 read (evfd, &counter, sizeof (uint64_t));
1197 { 1230 {
1198 char dummy; 1231 char dummy;
1199 read (evpipe [0], &dummy, 1); 1232 read (evpipe [0], &dummy, 1);
1200 } 1233 }
1201 1234
1202 if (gotsig && ev_is_default_loop (EV_A)) 1235 if (sig_pending)
1203 { 1236 {
1204 int signum; 1237 sig_pending = 0;
1205 gotsig = 0;
1206 1238
1207 for (signum = signalmax; signum--; ) 1239 for (i = EV_NSIG - 1; i--; )
1208 if (signals [signum].gotsig) 1240 if (expect_false (signals [i].pending))
1209 ev_feed_signal_event (EV_A_ signum + 1); 1241 ev_feed_signal_event (EV_A_ i + 1);
1210 } 1242 }
1211 1243
1212#if EV_ASYNC_ENABLE 1244#if EV_ASYNC_ENABLE
1213 if (gotasync) 1245 if (async_pending)
1214 { 1246 {
1215 int i; 1247 async_pending = 0;
1216 gotasync = 0;
1217 1248
1218 for (i = asynccnt; i--; ) 1249 for (i = asynccnt; i--; )
1219 if (asyncs [i]->sent) 1250 if (asyncs [i]->sent)
1220 { 1251 {
1221 asyncs [i]->sent = 0; 1252 asyncs [i]->sent = 0;
1229 1260
1230static void 1261static void
1231ev_sighandler (int signum) 1262ev_sighandler (int signum)
1232{ 1263{
1233#if EV_MULTIPLICITY 1264#if EV_MULTIPLICITY
1234 struct ev_loop *loop = &default_loop_struct; 1265 EV_P = signals [signum - 1].loop;
1235#endif 1266#endif
1236 1267
1237#if _WIN32 1268#if _WIN32
1238 signal (signum, ev_sighandler); 1269 signal (signum, ev_sighandler);
1239#endif 1270#endif
1240 1271
1241 signals [signum - 1].gotsig = 1; 1272 signals [signum - 1].pending = 1;
1242 evpipe_write (EV_A_ &gotsig); 1273 evpipe_write (EV_A_ &sig_pending);
1243} 1274}
1244 1275
1245void noinline 1276void noinline
1246ev_feed_signal_event (EV_P_ int signum) 1277ev_feed_signal_event (EV_P_ int signum)
1247{ 1278{
1248 WL w; 1279 WL w;
1249 1280
1281 if (expect_false (signum <= 0 || signum > EV_NSIG))
1282 return;
1283
1284 --signum;
1285
1250#if EV_MULTIPLICITY 1286#if EV_MULTIPLICITY
1251 assert (("libev: feeding signal events is only supported in the default loop", loop == ev_default_loop_ptr)); 1287 /* it is permissible to try to feed a signal to the wrong loop */
1252#endif 1288 /* or, likely more useful, feeding a signal nobody is waiting for */
1253 1289
1254 --signum; 1290 if (expect_false (signals [signum].loop != EV_A))
1255
1256 if (signum < 0 || signum >= signalmax)
1257 return; 1291 return;
1292#endif
1258 1293
1259 signals [signum].gotsig = 0; 1294 signals [signum].pending = 0;
1260 1295
1261 for (w = signals [signum].head; w; w = w->next) 1296 for (w = signals [signum].head; w; w = w->next)
1262 ev_feed_event (EV_A_ (W)w, EV_SIGNAL); 1297 ev_feed_event (EV_A_ (W)w, EV_SIGNAL);
1263} 1298}
1264 1299
1265#if EV_USE_SIGNALFD 1300#if EV_USE_SIGNALFD
1266static void 1301static void
1267sigfdcb (EV_P_ ev_io *iow, int revents) 1302sigfdcb (EV_P_ ev_io *iow, int revents)
1268{ 1303{
1269 struct signalfd_siginfo si[4], *sip; 1304 struct signalfd_siginfo si[2], *sip; /* these structs are big */
1270 1305
1271 for (;;) 1306 for (;;)
1272 { 1307 {
1273 ssize_t res = read (sigfd, si, sizeof (si)); 1308 ssize_t res = read (sigfd, si, sizeof (si));
1274 1309
1508 if (!clock_gettime (CLOCK_MONOTONIC, &ts)) 1543 if (!clock_gettime (CLOCK_MONOTONIC, &ts))
1509 have_monotonic = 1; 1544 have_monotonic = 1;
1510 } 1545 }
1511#endif 1546#endif
1512 1547
1548 /* pid check not overridable via env */
1549#ifndef _WIN32
1550 if (flags & EVFLAG_FORKCHECK)
1551 curpid = getpid ();
1552#endif
1553
1554 if (!(flags & EVFLAG_NOENV)
1555 && !enable_secure ()
1556 && getenv ("LIBEV_FLAGS"))
1557 flags = atoi (getenv ("LIBEV_FLAGS"));
1558
1513 ev_rt_now = ev_time (); 1559 ev_rt_now = ev_time ();
1514 mn_now = get_clock (); 1560 mn_now = get_clock ();
1515 now_floor = mn_now; 1561 now_floor = mn_now;
1516 rtmn_diff = ev_rt_now - mn_now; 1562 rtmn_diff = ev_rt_now - mn_now;
1517#if EV_MINIMAL < 2 1563#if EV_MINIMAL < 2
1520 1566
1521 io_blocktime = 0.; 1567 io_blocktime = 0.;
1522 timeout_blocktime = 0.; 1568 timeout_blocktime = 0.;
1523 backend = 0; 1569 backend = 0;
1524 backend_fd = -1; 1570 backend_fd = -1;
1525 gotasync = 0; 1571 sig_pending = 0;
1572#if EV_ASYNC_ENABLE
1573 async_pending = 0;
1574#endif
1526#if EV_USE_INOTIFY 1575#if EV_USE_INOTIFY
1527 fs_fd = -2; 1576 fs_fd = flags & EVFLAG_NOINOTIFY ? -1 : -2;
1528#endif 1577#endif
1529#if EV_USE_SIGNALFD 1578#if EV_USE_SIGNALFD
1530 sigfd = -2; 1579 sigfd = flags & EVFLAG_NOSIGFD ? -1 : -2;
1531#endif 1580#endif
1532
1533 /* pid check not overridable via env */
1534#ifndef _WIN32
1535 if (flags & EVFLAG_FORKCHECK)
1536 curpid = getpid ();
1537#endif
1538
1539 if (!(flags & EVFLAG_NOENV)
1540 && !enable_secure ()
1541 && getenv ("LIBEV_FLAGS"))
1542 flags = atoi (getenv ("LIBEV_FLAGS"));
1543 1581
1544 if (!(flags & 0x0000ffffU)) 1582 if (!(flags & 0x0000ffffU))
1545 flags |= ev_recommended_backends (); 1583 flags |= ev_recommended_backends ();
1546 1584
1547#if EV_USE_PORT 1585#if EV_USE_PORT
1630#if EV_IDLE_ENABLE 1668#if EV_IDLE_ENABLE
1631 array_free (idle, [i]); 1669 array_free (idle, [i]);
1632#endif 1670#endif
1633 } 1671 }
1634 1672
1635 ev_free (anfds); anfdmax = 0; 1673 ev_free (anfds); anfds = 0; anfdmax = 0;
1636 1674
1637 /* have to use the microsoft-never-gets-it-right macro */ 1675 /* have to use the microsoft-never-gets-it-right macro */
1638 array_free (rfeed, EMPTY); 1676 array_free (rfeed, EMPTY);
1639 array_free (fdchange, EMPTY); 1677 array_free (fdchange, EMPTY);
1640 array_free (timer, EMPTY); 1678 array_free (timer, EMPTY);
1675 1713
1676 if (ev_is_active (&pipe_w)) 1714 if (ev_is_active (&pipe_w))
1677 { 1715 {
1678 /* this "locks" the handlers against writing to the pipe */ 1716 /* this "locks" the handlers against writing to the pipe */
1679 /* while we modify the fd vars */ 1717 /* while we modify the fd vars */
1680 gotsig = 1; 1718 sig_pending = 1;
1681#if EV_ASYNC_ENABLE 1719#if EV_ASYNC_ENABLE
1682 gotasync = 1; 1720 async_pending = 1;
1683#endif 1721#endif
1684 1722
1685 ev_ref (EV_A); 1723 ev_ref (EV_A);
1686 ev_io_stop (EV_A_ &pipe_w); 1724 ev_io_stop (EV_A_ &pipe_w);
1687 1725
1707#if EV_MULTIPLICITY 1745#if EV_MULTIPLICITY
1708 1746
1709struct ev_loop * 1747struct ev_loop *
1710ev_loop_new (unsigned int flags) 1748ev_loop_new (unsigned int flags)
1711{ 1749{
1712 struct ev_loop *loop = (struct ev_loop *)ev_malloc (sizeof (struct ev_loop)); 1750 EV_P = (struct ev_loop *)ev_malloc (sizeof (struct ev_loop));
1713 1751
1714 memset (loop, 0, sizeof (struct ev_loop)); 1752 memset (EV_A, 0, sizeof (struct ev_loop));
1715 loop_init (EV_A_ flags); 1753 loop_init (EV_A_ flags);
1716 1754
1717 if (ev_backend (EV_A)) 1755 if (ev_backend (EV_A))
1718 return loop; 1756 return EV_A;
1719 1757
1720 return 0; 1758 return 0;
1721} 1759}
1722 1760
1723void 1761void
1827 assert (checkmax >= checkcnt); 1865 assert (checkmax >= checkcnt);
1828 array_verify (EV_A_ (W *)checks, checkcnt); 1866 array_verify (EV_A_ (W *)checks, checkcnt);
1829 1867
1830# if 0 1868# if 0
1831 for (w = (ev_child *)childs [chain & (EV_PID_HASHSIZE - 1)]; w; w = (ev_child *)((WL)w)->next) 1869 for (w = (ev_child *)childs [chain & (EV_PID_HASHSIZE - 1)]; w; w = (ev_child *)((WL)w)->next)
1832 for (signum = signalmax; signum--; ) if (signals [signum].gotsig) 1870 for (signum = EV_NSIG; signum--; ) if (signals [signum].pending)
1833# endif 1871# endif
1834#endif 1872#endif
1835} 1873}
1836#endif 1874#endif
1837 1875
1844#endif 1882#endif
1845{ 1883{
1846 if (!ev_default_loop_ptr) 1884 if (!ev_default_loop_ptr)
1847 { 1885 {
1848#if EV_MULTIPLICITY 1886#if EV_MULTIPLICITY
1849 struct ev_loop *loop = ev_default_loop_ptr = &default_loop_struct; 1887 EV_P = ev_default_loop_ptr = &default_loop_struct;
1850#else 1888#else
1851 ev_default_loop_ptr = 1; 1889 ev_default_loop_ptr = 1;
1852#endif 1890#endif
1853 1891
1854 loop_init (EV_A_ flags); 1892 loop_init (EV_A_ flags);
1871 1909
1872void 1910void
1873ev_default_destroy (void) 1911ev_default_destroy (void)
1874{ 1912{
1875#if EV_MULTIPLICITY 1913#if EV_MULTIPLICITY
1876 struct ev_loop *loop = ev_default_loop_ptr; 1914 EV_P = ev_default_loop_ptr;
1877#endif 1915#endif
1878 1916
1879 ev_default_loop_ptr = 0; 1917 ev_default_loop_ptr = 0;
1880 1918
1881#ifndef _WIN32 1919#ifndef _WIN32
1888 1926
1889void 1927void
1890ev_default_fork (void) 1928ev_default_fork (void)
1891{ 1929{
1892#if EV_MULTIPLICITY 1930#if EV_MULTIPLICITY
1893 struct ev_loop *loop = ev_default_loop_ptr; 1931 EV_P = ev_default_loop_ptr;
1894#endif 1932#endif
1895 1933
1896 postfork = 1; /* must be in line with ev_loop_fork */ 1934 postfork = 1; /* must be in line with ev_loop_fork */
1897} 1935}
1898 1936
2364inline_size void 2402inline_size void
2365wlist_del (WL *head, WL elem) 2403wlist_del (WL *head, WL elem)
2366{ 2404{
2367 while (*head) 2405 while (*head)
2368 { 2406 {
2369 if (*head == elem) 2407 if (expect_true (*head == elem))
2370 { 2408 {
2371 *head = elem->next; 2409 *head = elem->next;
2372 return; 2410 break;
2373 } 2411 }
2374 2412
2375 head = &(*head)->next; 2413 head = &(*head)->next;
2376 } 2414 }
2377} 2415}
2631#endif 2669#endif
2632 2670
2633void noinline 2671void noinline
2634ev_signal_start (EV_P_ ev_signal *w) 2672ev_signal_start (EV_P_ ev_signal *w)
2635{ 2673{
2636#if EV_MULTIPLICITY
2637 assert (("libev: signal watchers are only supported in the default loop", loop == ev_default_loop_ptr));
2638#endif
2639 if (expect_false (ev_is_active (w))) 2674 if (expect_false (ev_is_active (w)))
2640 return; 2675 return;
2641 2676
2642 assert (("libev: ev_signal_start called with illegal signal number", w->signum > 0)); 2677 assert (("libev: ev_signal_start called with illegal signal number", w->signum > 0 && w->signum < EV_NSIG));
2678
2679#if EV_MULTIPLICITY
2680 assert (("libev: a signal must not be attached to two different loops",
2681 !signals [w->signum - 1].loop || signals [w->signum - 1].loop == loop));
2682
2683 signals [w->signum - 1].loop = EV_A;
2684#endif
2643 2685
2644 EV_FREQUENT_CHECK; 2686 EV_FREQUENT_CHECK;
2645 2687
2646#if EV_USE_SIGNALFD 2688#if EV_USE_SIGNALFD
2647 if (sigfd == -2) 2689 if (sigfd == -2)
2669 sigaddset (&sigfd_set, w->signum); 2711 sigaddset (&sigfd_set, w->signum);
2670 sigprocmask (SIG_BLOCK, &sigfd_set, 0); 2712 sigprocmask (SIG_BLOCK, &sigfd_set, 0);
2671 2713
2672 signalfd (sigfd, &sigfd_set, 0); 2714 signalfd (sigfd, &sigfd_set, 0);
2673 } 2715 }
2674 else
2675#endif 2716#endif
2676 evpipe_init (EV_A);
2677
2678 {
2679#ifndef _WIN32
2680 sigset_t full, prev;
2681 sigfillset (&full);
2682 sigprocmask (SIG_SETMASK, &full, &prev);
2683#endif
2684
2685 array_needsize (ANSIG, signals, signalmax, w->signum, array_init_zero);
2686
2687#ifndef _WIN32
2688 if (sigfd < 0)/*TODO*/
2689 sigdelset (&prev, w->signum);
2690 sigprocmask (SIG_SETMASK, &prev, 0);
2691#endif
2692 }
2693 2717
2694 ev_start (EV_A_ (W)w, 1); 2718 ev_start (EV_A_ (W)w, 1);
2695 wlist_add (&signals [w->signum - 1].head, (WL)w); 2719 wlist_add (&signals [w->signum - 1].head, (WL)w);
2696 2720
2697 if (!((WL)w)->next) 2721 if (!((WL)w)->next)
2722# if EV_USE_SIGNALFD
2723 if (sigfd < 0) /*TODO*/
2724# endif
2698 { 2725 {
2699#if _WIN32 2726# if _WIN32
2700 signal (w->signum, ev_sighandler); 2727 signal (w->signum, ev_sighandler);
2701#else 2728# else
2702 if (sigfd < 0) /*TODO*/
2703 {
2704 struct sigaction sa = { }; 2729 struct sigaction sa;
2730
2731 evpipe_init (EV_A);
2732
2705 sa.sa_handler = ev_sighandler; 2733 sa.sa_handler = ev_sighandler;
2706 sigfillset (&sa.sa_mask); 2734 sigfillset (&sa.sa_mask);
2707 sa.sa_flags = SA_RESTART; /* if restarting works we save one iteration */ 2735 sa.sa_flags = SA_RESTART; /* if restarting works we save one iteration */
2708 sigaction (w->signum, &sa, 0); 2736 sigaction (w->signum, &sa, 0);
2737
2738 sigemptyset (&sa.sa_mask);
2739 sigaddset (&sa.sa_mask, w->signum);
2740 sigprocmask (SIG_UNBLOCK, &sa.sa_mask, 0);
2741#endif
2709 } 2742 }
2710#endif
2711 }
2712 2743
2713 EV_FREQUENT_CHECK; 2744 EV_FREQUENT_CHECK;
2714} 2745}
2715 2746
2716void noinline 2747void noinline
2724 2755
2725 wlist_del (&signals [w->signum - 1].head, (WL)w); 2756 wlist_del (&signals [w->signum - 1].head, (WL)w);
2726 ev_stop (EV_A_ (W)w); 2757 ev_stop (EV_A_ (W)w);
2727 2758
2728 if (!signals [w->signum - 1].head) 2759 if (!signals [w->signum - 1].head)
2760 {
2761#if EV_MULTIPLICITY
2762 signals [w->signum - 1].loop = 0; /* unattach from signal */
2763#endif
2729#if EV_USE_SIGNALFD 2764#if EV_USE_SIGNALFD
2730 if (sigfd >= 0) 2765 if (sigfd >= 0)
2731 { 2766 {
2732 sigprocmask (SIG_UNBLOCK, &sigfd_set, 0);//D 2767 sigprocmask (SIG_UNBLOCK, &sigfd_set, 0);//D
2733 sigdelset (&sigfd_set, w->signum); 2768 sigdelset (&sigfd_set, w->signum);
2734 signalfd (sigfd, &sigfd_set, 0); 2769 signalfd (sigfd, &sigfd_set, 0);
2735 sigprocmask (SIG_BLOCK, &sigfd_set, 0);//D 2770 sigprocmask (SIG_BLOCK, &sigfd_set, 0);//D
2736 /*TODO: maybe unblock signal? */ 2771 /*TODO: maybe unblock signal? */
2737 } 2772 }
2738 else 2773 else
2739#endif 2774#endif
2740 signal (w->signum, SIG_DFL); 2775 signal (w->signum, SIG_DFL);
2776 }
2741 2777
2742 EV_FREQUENT_CHECK; 2778 EV_FREQUENT_CHECK;
2743} 2779}
2744 2780
2745void 2781void
3225embed_prepare_cb (EV_P_ ev_prepare *prepare, int revents) 3261embed_prepare_cb (EV_P_ ev_prepare *prepare, int revents)
3226{ 3262{
3227 ev_embed *w = (ev_embed *)(((char *)prepare) - offsetof (ev_embed, prepare)); 3263 ev_embed *w = (ev_embed *)(((char *)prepare) - offsetof (ev_embed, prepare));
3228 3264
3229 { 3265 {
3230 struct ev_loop *loop = w->other; 3266 EV_P = w->other;
3231 3267
3232 while (fdchangecnt) 3268 while (fdchangecnt)
3233 { 3269 {
3234 fd_reify (EV_A); 3270 fd_reify (EV_A);
3235 ev_loop (EV_A_ EVLOOP_NONBLOCK); 3271 ev_loop (EV_A_ EVLOOP_NONBLOCK);
3243 ev_embed *w = (ev_embed *)(((char *)fork_w) - offsetof (ev_embed, fork)); 3279 ev_embed *w = (ev_embed *)(((char *)fork_w) - offsetof (ev_embed, fork));
3244 3280
3245 ev_embed_stop (EV_A_ w); 3281 ev_embed_stop (EV_A_ w);
3246 3282
3247 { 3283 {
3248 struct ev_loop *loop = w->other; 3284 EV_P = w->other;
3249 3285
3250 ev_loop_fork (EV_A); 3286 ev_loop_fork (EV_A);
3251 ev_loop (EV_A_ EVLOOP_NONBLOCK); 3287 ev_loop (EV_A_ EVLOOP_NONBLOCK);
3252 } 3288 }
3253 3289
3267{ 3303{
3268 if (expect_false (ev_is_active (w))) 3304 if (expect_false (ev_is_active (w)))
3269 return; 3305 return;
3270 3306
3271 { 3307 {
3272 struct ev_loop *loop = w->other; 3308 EV_P = w->other;
3273 assert (("libev: loop to be embedded is not embeddable", backend & ev_embeddable_backends ())); 3309 assert (("libev: loop to be embedded is not embeddable", backend & ev_embeddable_backends ()));
3274 ev_io_init (&w->io, embed_io_cb, backend_fd, EV_READ); 3310 ev_io_init (&w->io, embed_io_cb, backend_fd, EV_READ);
3275 } 3311 }
3276 3312
3277 EV_FREQUENT_CHECK; 3313 EV_FREQUENT_CHECK;
3389 3425
3390void 3426void
3391ev_async_send (EV_P_ ev_async *w) 3427ev_async_send (EV_P_ ev_async *w)
3392{ 3428{
3393 w->sent = 1; 3429 w->sent = 1;
3394 evpipe_write (EV_A_ &gotasync); 3430 evpipe_write (EV_A_ &async_pending);
3395} 3431}
3396#endif 3432#endif
3397 3433
3398/*****************************************************************************/ 3434/*****************************************************************************/
3399 3435
3548 if (types & EV_CHECK) 3584 if (types & EV_CHECK)
3549 for (i = checkcnt; i--; ) 3585 for (i = checkcnt; i--; )
3550 cb (EV_A_ EV_CHECK, checks [i]); 3586 cb (EV_A_ EV_CHECK, checks [i]);
3551 3587
3552 if (types & EV_SIGNAL) 3588 if (types & EV_SIGNAL)
3553 for (i = 0; i < signalmax; ++i) 3589 for (i = 0; i < EV_NSIG - 1; ++i)
3554 for (wl = signals [i].head; wl; ) 3590 for (wl = signals [i].head; wl; )
3555 { 3591 {
3556 wn = wl->next; 3592 wn = wl->next;
3557 cb (EV_A_ EV_SIGNAL, wl); 3593 cb (EV_A_ EV_SIGNAL, wl);
3558 wl = wn; 3594 wl = wn;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines