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

Comparing libev/ev.c (file contents):
Revision 1.305 by root, Sun Jul 19 03:49:04 2009 UTC vs.
Revision 1.312 by root, Wed Aug 12 18:48:17 2009 UTC

210#elif defined (_sys_nsig) 210#elif defined (_sys_nsig)
211# define EV_NSIG (_sys_nsig) /* Solaris 2.5 */ 211# define EV_NSIG (_sys_nsig) /* Solaris 2.5 */
212#else 212#else
213# error "unable to find value for NSIG, please report" 213# error "unable to find value for NSIG, please report"
214/* to make it compile regardless, just remove the above line */ 214/* to make it compile regardless, just remove the above line */
215# define EV_NSIG 64 215# define EV_NSIG 65
216#endif 216#endif
217 217
218/* Default to some arbitrary number that's big enough to get most
219 of the common signals.
220*/
221#ifndef NSIG
222# define NSIG 50
223#endif
224/* <-- NSIG logic from Configure */
225#ifndef EV_USE_CLOCK_SYSCALL 218#ifndef EV_USE_CLOCK_SYSCALL
226# if __linux && __GLIBC__ >= 2 219# if __linux && __GLIBC__ >= 2
227# define EV_USE_CLOCK_SYSCALL 1 220# define EV_USE_CLOCK_SYSCALL 1
228# else 221# else
229# define EV_USE_CLOCK_SYSCALL 0 222# define EV_USE_CLOCK_SYSCALL 0
393# include <stdint.h> 386# include <stdint.h>
394# ifndef EFD_NONBLOCK 387# ifndef EFD_NONBLOCK
395# define EFD_NONBLOCK O_NONBLOCK 388# define EFD_NONBLOCK O_NONBLOCK
396# endif 389# endif
397# ifndef EFD_CLOEXEC 390# ifndef EFD_CLOEXEC
391# ifdef O_CLOEXEC
398# define EFD_CLOEXEC O_CLOEXEC 392# define EFD_CLOEXEC O_CLOEXEC
393# else
394# define EFD_CLOEXEC 02000000
395# endif
399# endif 396# endif
400# ifdef __cplusplus 397# ifdef __cplusplus
401extern "C" { 398extern "C" {
402# endif 399# endif
403int eventfd (unsigned int initval, int flags); 400int eventfd (unsigned int initval, int flags);
964 961
965 for (fd = anfdmax; fd--; ) 962 for (fd = anfdmax; fd--; )
966 if (anfds [fd].events) 963 if (anfds [fd].events)
967 { 964 {
968 fd_kill (EV_A_ fd); 965 fd_kill (EV_A_ fd);
969 return; 966 break;
970 } 967 }
971} 968}
972 969
973/* 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 */
974static void noinline 971static void noinline
1064 1061
1065 for (;;) 1062 for (;;)
1066 { 1063 {
1067 int c = k << 1; 1064 int c = k << 1;
1068 1065
1069 if (c > N + HEAP0 - 1) 1066 if (c >= N + HEAP0)
1070 break; 1067 break;
1071 1068
1072 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])
1073 ? 1 : 0; 1070 ? 1 : 0;
1074 1071
1110 1107
1111/* move an element suitably so it is in a correct place */ 1108/* move an element suitably so it is in a correct place */
1112inline_size void 1109inline_size void
1113adjustheap (ANHE *heap, int N, int k) 1110adjustheap (ANHE *heap, int N, int k)
1114{ 1111{
1115 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)]))
1116 upheap (heap, k); 1113 upheap (heap, k);
1117 else 1114 else
1118 downheap (heap, N, k); 1115 downheap (heap, N, k);
1119} 1116}
1120 1117
1133/*****************************************************************************/ 1130/*****************************************************************************/
1134 1131
1135/* associate signal watchers to a signal signal */ 1132/* associate signal watchers to a signal signal */
1136typedef struct 1133typedef struct
1137{ 1134{
1135 EV_ATOMIC_T pending;
1136#if EV_MULTIPLICITY
1137 EV_P;
1138#endif
1138 WL head; 1139 WL head;
1139 EV_ATOMIC_T gotsig;
1140} ANSIG; 1140} ANSIG;
1141 1141
1142static ANSIG *signals; 1142static ANSIG signals [EV_NSIG - 1];
1143static int signalmax;
1144
1145static EV_ATOMIC_T gotsig;
1146 1143
1147/*****************************************************************************/ 1144/*****************************************************************************/
1148 1145
1149/* used to prepare libev internal fd's */ 1146/* used to prepare libev internal fd's */
1150/* this is not fork-safe */ 1147/* this is not fork-safe */
1218/* called whenever the libev signal pipe */ 1215/* called whenever the libev signal pipe */
1219/* got some events (signal, async) */ 1216/* got some events (signal, async) */
1220static void 1217static void
1221pipecb (EV_P_ ev_io *iow, int revents) 1218pipecb (EV_P_ ev_io *iow, int revents)
1222{ 1219{
1220 int i;
1221
1223#if EV_USE_EVENTFD 1222#if EV_USE_EVENTFD
1224 if (evfd >= 0) 1223 if (evfd >= 0)
1225 { 1224 {
1226 uint64_t counter; 1225 uint64_t counter;
1227 read (evfd, &counter, sizeof (uint64_t)); 1226 read (evfd, &counter, sizeof (uint64_t));
1231 { 1230 {
1232 char dummy; 1231 char dummy;
1233 read (evpipe [0], &dummy, 1); 1232 read (evpipe [0], &dummy, 1);
1234 } 1233 }
1235 1234
1236 if (gotsig && ev_is_default_loop (EV_A)) 1235 if (sig_pending)
1237 { 1236 {
1238 int signum; 1237 sig_pending = 0;
1239 gotsig = 0;
1240 1238
1241 for (signum = signalmax; signum--; ) 1239 for (i = EV_NSIG - 1; i--; )
1242 if (signals [signum].gotsig) 1240 if (expect_false (signals [i].pending))
1243 ev_feed_signal_event (EV_A_ signum + 1); 1241 ev_feed_signal_event (EV_A_ i + 1);
1244 } 1242 }
1245 1243
1246#if EV_ASYNC_ENABLE 1244#if EV_ASYNC_ENABLE
1247 if (gotasync) 1245 if (async_pending)
1248 { 1246 {
1249 int i; 1247 async_pending = 0;
1250 gotasync = 0;
1251 1248
1252 for (i = asynccnt; i--; ) 1249 for (i = asynccnt; i--; )
1253 if (asyncs [i]->sent) 1250 if (asyncs [i]->sent)
1254 { 1251 {
1255 asyncs [i]->sent = 0; 1252 asyncs [i]->sent = 0;
1263 1260
1264static void 1261static void
1265ev_sighandler (int signum) 1262ev_sighandler (int signum)
1266{ 1263{
1267#if EV_MULTIPLICITY 1264#if EV_MULTIPLICITY
1268 struct ev_loop *loop = &default_loop_struct; 1265 EV_P = signals [signum - 1].loop;
1269#endif 1266#endif
1270 1267
1271#if _WIN32 1268#if _WIN32
1272 signal (signum, ev_sighandler); 1269 signal (signum, ev_sighandler);
1273#endif 1270#endif
1274 1271
1275 signals [signum - 1].gotsig = 1; 1272 signals [signum - 1].pending = 1;
1276 evpipe_write (EV_A_ &gotsig); 1273 evpipe_write (EV_A_ &sig_pending);
1277} 1274}
1278 1275
1279void noinline 1276void noinline
1280ev_feed_signal_event (EV_P_ int signum) 1277ev_feed_signal_event (EV_P_ int signum)
1281{ 1278{
1282 WL w; 1279 WL w;
1283 1280
1281 if (expect_false (signum <= 0 || signum > EV_NSIG))
1282 return;
1283
1284 --signum;
1285
1284#if EV_MULTIPLICITY 1286#if EV_MULTIPLICITY
1285 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 */
1286#endif 1288 /* or, likely more useful, feeding a signal nobody is waiting for */
1287 1289
1288 --signum; 1290 if (expect_false (signals [signum].loop != EV_A))
1289
1290 if (signum < 0 || signum >= signalmax)
1291 return; 1291 return;
1292#endif
1292 1293
1293 signals [signum].gotsig = 0; 1294 signals [signum].pending = 0;
1294 1295
1295 for (w = signals [signum].head; w; w = w->next) 1296 for (w = signals [signum].head; w; w = w->next)
1296 ev_feed_event (EV_A_ (W)w, EV_SIGNAL); 1297 ev_feed_event (EV_A_ (W)w, EV_SIGNAL);
1297} 1298}
1298 1299
1299#if EV_USE_SIGNALFD 1300#if EV_USE_SIGNALFD
1300static void 1301static void
1301sigfdcb (EV_P_ ev_io *iow, int revents) 1302sigfdcb (EV_P_ ev_io *iow, int revents)
1302{ 1303{
1303 struct signalfd_siginfo si[4], *sip; 1304 struct signalfd_siginfo si[2], *sip; /* these structs are big */
1304 1305
1305 for (;;) 1306 for (;;)
1306 { 1307 {
1307 ssize_t res = read (sigfd, si, sizeof (si)); 1308 ssize_t res = read (sigfd, si, sizeof (si));
1308 1309
1542 if (!clock_gettime (CLOCK_MONOTONIC, &ts)) 1543 if (!clock_gettime (CLOCK_MONOTONIC, &ts))
1543 have_monotonic = 1; 1544 have_monotonic = 1;
1544 } 1545 }
1545#endif 1546#endif
1546 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
1547 ev_rt_now = ev_time (); 1559 ev_rt_now = ev_time ();
1548 mn_now = get_clock (); 1560 mn_now = get_clock ();
1549 now_floor = mn_now; 1561 now_floor = mn_now;
1550 rtmn_diff = ev_rt_now - mn_now; 1562 rtmn_diff = ev_rt_now - mn_now;
1551#if EV_MINIMAL < 2 1563#if EV_MINIMAL < 2
1554 1566
1555 io_blocktime = 0.; 1567 io_blocktime = 0.;
1556 timeout_blocktime = 0.; 1568 timeout_blocktime = 0.;
1557 backend = 0; 1569 backend = 0;
1558 backend_fd = -1; 1570 backend_fd = -1;
1559 gotasync = 0; 1571 sig_pending = 0;
1572#if EV_ASYNC_ENABLE
1573 async_pending = 0;
1574#endif
1560#if EV_USE_INOTIFY 1575#if EV_USE_INOTIFY
1561 fs_fd = -2; 1576 fs_fd = flags & EVFLAG_NOINOTIFY ? -1 : -2;
1562#endif 1577#endif
1563#if EV_USE_SIGNALFD 1578#if EV_USE_SIGNALFD
1564 sigfd = -2; 1579 sigfd = flags & EVFLAG_NOSIGFD ? -1 : -2;
1565#endif 1580#endif
1566
1567 /* pid check not overridable via env */
1568#ifndef _WIN32
1569 if (flags & EVFLAG_FORKCHECK)
1570 curpid = getpid ();
1571#endif
1572
1573 if (!(flags & EVFLAG_NOENV)
1574 && !enable_secure ()
1575 && getenv ("LIBEV_FLAGS"))
1576 flags = atoi (getenv ("LIBEV_FLAGS"));
1577 1581
1578 if (!(flags & 0x0000ffffU)) 1582 if (!(flags & 0x0000ffffU))
1579 flags |= ev_recommended_backends (); 1583 flags |= ev_recommended_backends ();
1580 1584
1581#if EV_USE_PORT 1585#if EV_USE_PORT
1709 1713
1710 if (ev_is_active (&pipe_w)) 1714 if (ev_is_active (&pipe_w))
1711 { 1715 {
1712 /* this "locks" the handlers against writing to the pipe */ 1716 /* this "locks" the handlers against writing to the pipe */
1713 /* while we modify the fd vars */ 1717 /* while we modify the fd vars */
1714 gotsig = 1; 1718 sig_pending = 1;
1715#if EV_ASYNC_ENABLE 1719#if EV_ASYNC_ENABLE
1716 gotasync = 1; 1720 async_pending = 1;
1717#endif 1721#endif
1718 1722
1719 ev_ref (EV_A); 1723 ev_ref (EV_A);
1720 ev_io_stop (EV_A_ &pipe_w); 1724 ev_io_stop (EV_A_ &pipe_w);
1721 1725
1741#if EV_MULTIPLICITY 1745#if EV_MULTIPLICITY
1742 1746
1743struct ev_loop * 1747struct ev_loop *
1744ev_loop_new (unsigned int flags) 1748ev_loop_new (unsigned int flags)
1745{ 1749{
1746 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));
1747 1751
1748 memset (loop, 0, sizeof (struct ev_loop)); 1752 memset (EV_A, 0, sizeof (struct ev_loop));
1749 loop_init (EV_A_ flags); 1753 loop_init (EV_A_ flags);
1750 1754
1751 if (ev_backend (EV_A)) 1755 if (ev_backend (EV_A))
1752 return loop; 1756 return EV_A;
1753 1757
1754 return 0; 1758 return 0;
1755} 1759}
1756 1760
1757void 1761void
1861 assert (checkmax >= checkcnt); 1865 assert (checkmax >= checkcnt);
1862 array_verify (EV_A_ (W *)checks, checkcnt); 1866 array_verify (EV_A_ (W *)checks, checkcnt);
1863 1867
1864# if 0 1868# if 0
1865 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)
1866 for (signum = signalmax; signum--; ) if (signals [signum].gotsig) 1870 for (signum = EV_NSIG; signum--; ) if (signals [signum].pending)
1867# endif 1871# endif
1868#endif 1872#endif
1869} 1873}
1870#endif 1874#endif
1871 1875
1878#endif 1882#endif
1879{ 1883{
1880 if (!ev_default_loop_ptr) 1884 if (!ev_default_loop_ptr)
1881 { 1885 {
1882#if EV_MULTIPLICITY 1886#if EV_MULTIPLICITY
1883 struct ev_loop *loop = ev_default_loop_ptr = &default_loop_struct; 1887 EV_P = ev_default_loop_ptr = &default_loop_struct;
1884#else 1888#else
1885 ev_default_loop_ptr = 1; 1889 ev_default_loop_ptr = 1;
1886#endif 1890#endif
1887 1891
1888 loop_init (EV_A_ flags); 1892 loop_init (EV_A_ flags);
1905 1909
1906void 1910void
1907ev_default_destroy (void) 1911ev_default_destroy (void)
1908{ 1912{
1909#if EV_MULTIPLICITY 1913#if EV_MULTIPLICITY
1910 struct ev_loop *loop = ev_default_loop_ptr; 1914 EV_P = ev_default_loop_ptr;
1911#endif 1915#endif
1912 1916
1913 ev_default_loop_ptr = 0; 1917 ev_default_loop_ptr = 0;
1914 1918
1915#ifndef _WIN32 1919#ifndef _WIN32
1922 1926
1923void 1927void
1924ev_default_fork (void) 1928ev_default_fork (void)
1925{ 1929{
1926#if EV_MULTIPLICITY 1930#if EV_MULTIPLICITY
1927 struct ev_loop *loop = ev_default_loop_ptr; 1931 EV_P = ev_default_loop_ptr;
1928#endif 1932#endif
1929 1933
1930 postfork = 1; /* must be in line with ev_loop_fork */ 1934 postfork = 1; /* must be in line with ev_loop_fork */
1931} 1935}
1932 1936
2398inline_size void 2402inline_size void
2399wlist_del (WL *head, WL elem) 2403wlist_del (WL *head, WL elem)
2400{ 2404{
2401 while (*head) 2405 while (*head)
2402 { 2406 {
2403 if (*head == elem) 2407 if (expect_true (*head == elem))
2404 { 2408 {
2405 *head = elem->next; 2409 *head = elem->next;
2406 return; 2410 break;
2407 } 2411 }
2408 2412
2409 head = &(*head)->next; 2413 head = &(*head)->next;
2410 } 2414 }
2411} 2415}
2665#endif 2669#endif
2666 2670
2667void noinline 2671void noinline
2668ev_signal_start (EV_P_ ev_signal *w) 2672ev_signal_start (EV_P_ ev_signal *w)
2669{ 2673{
2670#if EV_MULTIPLICITY
2671 assert (("libev: signal watchers are only supported in the default loop", loop == ev_default_loop_ptr));
2672#endif
2673 if (expect_false (ev_is_active (w))) 2674 if (expect_false (ev_is_active (w)))
2674 return; 2675 return;
2675 2676
2676 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
2677 2685
2678 EV_FREQUENT_CHECK; 2686 EV_FREQUENT_CHECK;
2679 2687
2680#if EV_USE_SIGNALFD 2688#if EV_USE_SIGNALFD
2681 if (sigfd == -2) 2689 if (sigfd == -2)
2703 sigaddset (&sigfd_set, w->signum); 2711 sigaddset (&sigfd_set, w->signum);
2704 sigprocmask (SIG_BLOCK, &sigfd_set, 0); 2712 sigprocmask (SIG_BLOCK, &sigfd_set, 0);
2705 2713
2706 signalfd (sigfd, &sigfd_set, 0); 2714 signalfd (sigfd, &sigfd_set, 0);
2707 } 2715 }
2708 else
2709#endif
2710 evpipe_init (EV_A);
2711
2712 {
2713#ifndef _WIN32
2714 sigset_t full, prev;
2715 sigfillset (&full);
2716 sigprocmask (SIG_SETMASK, &full, &prev);
2717#endif
2718
2719 array_needsize (ANSIG, signals, signalmax, w->signum, array_init_zero);
2720
2721#ifndef _WIN32
2722# if EV_USE_SIGNALFD
2723 if (sigfd < 0)/*TODO*/
2724# endif 2716#endif
2725 sigdelset (&prev, w->signum);
2726 sigprocmask (SIG_SETMASK, &prev, 0);
2727#endif
2728 }
2729 2717
2730 ev_start (EV_A_ (W)w, 1); 2718 ev_start (EV_A_ (W)w, 1);
2731 wlist_add (&signals [w->signum - 1].head, (WL)w); 2719 wlist_add (&signals [w->signum - 1].head, (WL)w);
2732 2720
2733 if (!((WL)w)->next) 2721 if (!((WL)w)->next)
2734 {
2735#if _WIN32
2736 signal (w->signum, ev_sighandler);
2737#else
2738# if EV_USE_SIGNALFD 2722# if EV_USE_SIGNALFD
2739 if (sigfd < 0) /*TODO*/ 2723 if (sigfd < 0) /*TODO*/
2740# endif 2724# endif
2741 { 2725 {
2726# if _WIN32
2727 signal (w->signum, ev_sighandler);
2728# else
2742 struct sigaction sa = { }; 2729 struct sigaction sa;
2730
2731 evpipe_init (EV_A);
2732
2743 sa.sa_handler = ev_sighandler; 2733 sa.sa_handler = ev_sighandler;
2744 sigfillset (&sa.sa_mask); 2734 sigfillset (&sa.sa_mask);
2745 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 */
2746 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
2747 } 2742 }
2748#endif
2749 }
2750 2743
2751 EV_FREQUENT_CHECK; 2744 EV_FREQUENT_CHECK;
2752} 2745}
2753 2746
2754void noinline 2747void noinline
2762 2755
2763 wlist_del (&signals [w->signum - 1].head, (WL)w); 2756 wlist_del (&signals [w->signum - 1].head, (WL)w);
2764 ev_stop (EV_A_ (W)w); 2757 ev_stop (EV_A_ (W)w);
2765 2758
2766 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
2767#if EV_USE_SIGNALFD 2764#if EV_USE_SIGNALFD
2768 if (sigfd >= 0) 2765 if (sigfd >= 0)
2769 { 2766 {
2770 sigprocmask (SIG_UNBLOCK, &sigfd_set, 0);//D 2767 sigprocmask (SIG_UNBLOCK, &sigfd_set, 0);//D
2771 sigdelset (&sigfd_set, w->signum); 2768 sigdelset (&sigfd_set, w->signum);
2772 signalfd (sigfd, &sigfd_set, 0); 2769 signalfd (sigfd, &sigfd_set, 0);
2773 sigprocmask (SIG_BLOCK, &sigfd_set, 0);//D 2770 sigprocmask (SIG_BLOCK, &sigfd_set, 0);//D
2774 /*TODO: maybe unblock signal? */ 2771 /*TODO: maybe unblock signal? */
2775 } 2772 }
2776 else 2773 else
2777#endif 2774#endif
2778 signal (w->signum, SIG_DFL); 2775 signal (w->signum, SIG_DFL);
2776 }
2779 2777
2780 EV_FREQUENT_CHECK; 2778 EV_FREQUENT_CHECK;
2781} 2779}
2782 2780
2783void 2781void
2863 } 2861 }
2864 } 2862 }
2865 2863
2866 if (w->wd >= 0) 2864 if (w->wd >= 0)
2867 { 2865 {
2866 struct statfs sfs;
2867
2868 wlist_add (&fs_hash [w->wd & (EV_INOTIFY_HASHSIZE - 1)].head, (WL)w); 2868 wlist_add (&fs_hash [w->wd & (EV_INOTIFY_HASHSIZE - 1)].head, (WL)w);
2869 2869
2870 /* now local changes will be tracked by inotify, but remote changes won't */ 2870 /* now local changes will be tracked by inotify, but remote changes won't */
2871 /* unless the filesystem it known to be local, we therefore still poll */ 2871 /* unless the filesystem it known to be local, we therefore still poll */
2872 /* also do poll on <2.6.25, but with normal frequency */ 2872 /* also do poll on <2.6.25, but with normal frequency */
2873 struct statfs sfs;
2874 2873
2875 if (fs_2625 && !statfs (w->path, &sfs)) 2874 if (fs_2625 && !statfs (w->path, &sfs))
2876 if (sfs.f_type == 0x1373 /* devfs */ 2875 if (sfs.f_type == 0x1373 /* devfs */
2877 || sfs.f_type == 0xEF53 /* ext2/3 */ 2876 || sfs.f_type == 0xEF53 /* ext2/3 */
2878 || sfs.f_type == 0x3153464a /* jfs */ 2877 || sfs.f_type == 0x3153464a /* jfs */
3263embed_prepare_cb (EV_P_ ev_prepare *prepare, int revents) 3262embed_prepare_cb (EV_P_ ev_prepare *prepare, int revents)
3264{ 3263{
3265 ev_embed *w = (ev_embed *)(((char *)prepare) - offsetof (ev_embed, prepare)); 3264 ev_embed *w = (ev_embed *)(((char *)prepare) - offsetof (ev_embed, prepare));
3266 3265
3267 { 3266 {
3268 struct ev_loop *loop = w->other; 3267 EV_P = w->other;
3269 3268
3270 while (fdchangecnt) 3269 while (fdchangecnt)
3271 { 3270 {
3272 fd_reify (EV_A); 3271 fd_reify (EV_A);
3273 ev_loop (EV_A_ EVLOOP_NONBLOCK); 3272 ev_loop (EV_A_ EVLOOP_NONBLOCK);
3281 ev_embed *w = (ev_embed *)(((char *)fork_w) - offsetof (ev_embed, fork)); 3280 ev_embed *w = (ev_embed *)(((char *)fork_w) - offsetof (ev_embed, fork));
3282 3281
3283 ev_embed_stop (EV_A_ w); 3282 ev_embed_stop (EV_A_ w);
3284 3283
3285 { 3284 {
3286 struct ev_loop *loop = w->other; 3285 EV_P = w->other;
3287 3286
3288 ev_loop_fork (EV_A); 3287 ev_loop_fork (EV_A);
3289 ev_loop (EV_A_ EVLOOP_NONBLOCK); 3288 ev_loop (EV_A_ EVLOOP_NONBLOCK);
3290 } 3289 }
3291 3290
3305{ 3304{
3306 if (expect_false (ev_is_active (w))) 3305 if (expect_false (ev_is_active (w)))
3307 return; 3306 return;
3308 3307
3309 { 3308 {
3310 struct ev_loop *loop = w->other; 3309 EV_P = w->other;
3311 assert (("libev: loop to be embedded is not embeddable", backend & ev_embeddable_backends ())); 3310 assert (("libev: loop to be embedded is not embeddable", backend & ev_embeddable_backends ()));
3312 ev_io_init (&w->io, embed_io_cb, backend_fd, EV_READ); 3311 ev_io_init (&w->io, embed_io_cb, backend_fd, EV_READ);
3313 } 3312 }
3314 3313
3315 EV_FREQUENT_CHECK; 3314 EV_FREQUENT_CHECK;
3427 3426
3428void 3427void
3429ev_async_send (EV_P_ ev_async *w) 3428ev_async_send (EV_P_ ev_async *w)
3430{ 3429{
3431 w->sent = 1; 3430 w->sent = 1;
3432 evpipe_write (EV_A_ &gotasync); 3431 evpipe_write (EV_A_ &async_pending);
3433} 3432}
3434#endif 3433#endif
3435 3434
3436/*****************************************************************************/ 3435/*****************************************************************************/
3437 3436
3586 if (types & EV_CHECK) 3585 if (types & EV_CHECK)
3587 for (i = checkcnt; i--; ) 3586 for (i = checkcnt; i--; )
3588 cb (EV_A_ EV_CHECK, checks [i]); 3587 cb (EV_A_ EV_CHECK, checks [i]);
3589 3588
3590 if (types & EV_SIGNAL) 3589 if (types & EV_SIGNAL)
3591 for (i = 0; i < signalmax; ++i) 3590 for (i = 0; i < EV_NSIG - 1; ++i)
3592 for (wl = signals [i].head; wl; ) 3591 for (wl = signals [i].head; wl; )
3593 { 3592 {
3594 wn = wl->next; 3593 wn = wl->next;
3595 cb (EV_A_ EV_SIGNAL, wl); 3594 cb (EV_A_ EV_SIGNAL, wl);
3596 wl = wn; 3595 wl = wn;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines