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

Comparing libev/ev.c (file contents):
Revision 1.177 by root, Tue Dec 11 15:06:50 2007 UTC vs.
Revision 1.183 by root, Wed Dec 12 05:11:56 2007 UTC

476 pendings [pri][w_->pending - 1].w = w_; 476 pendings [pri][w_->pending - 1].w = w_;
477 pendings [pri][w_->pending - 1].events = revents; 477 pendings [pri][w_->pending - 1].events = revents;
478 } 478 }
479} 479}
480 480
481void inline_size 481void inline_speed
482queue_events (EV_P_ W *events, int eventcnt, int type) 482queue_events (EV_P_ W *events, int eventcnt, int type)
483{ 483{
484 int i; 484 int i;
485 485
486 for (i = 0; i < eventcnt; ++i) 486 for (i = 0; i < eventcnt; ++i)
557 557
558 fdchangecnt = 0; 558 fdchangecnt = 0;
559} 559}
560 560
561void inline_size 561void inline_size
562fd_change (EV_P_ int fd) 562fd_change (EV_P_ int fd, int flags)
563{ 563{
564 if (expect_false (anfds [fd].reify)) 564 unsigned char reify = anfds [fd].reify;
565 return;
566
567 anfds [fd].reify = 1; 565 anfds [fd].reify |= flags | 1;
568 566
567 if (expect_true (!reify))
568 {
569 ++fdchangecnt; 569 ++fdchangecnt;
570 array_needsize (int, fdchanges, fdchangemax, fdchangecnt, EMPTY2); 570 array_needsize (int, fdchanges, fdchangemax, fdchangecnt, EMPTY2);
571 fdchanges [fdchangecnt - 1] = fd; 571 fdchanges [fdchangecnt - 1] = fd;
572 }
572} 573}
573 574
574void inline_speed 575void inline_speed
575fd_kill (EV_P_ int fd) 576fd_kill (EV_P_ int fd)
576{ 577{
627 628
628 for (fd = 0; fd < anfdmax; ++fd) 629 for (fd = 0; fd < anfdmax; ++fd)
629 if (anfds [fd].events) 630 if (anfds [fd].events)
630 { 631 {
631 anfds [fd].events = 0; 632 anfds [fd].events = 0;
632 fd_change (EV_A_ fd); 633 fd_change (EV_A_ fd, EV_IOFDSET);
633 } 634 }
634} 635}
635 636
636/*****************************************************************************/ 637/*****************************************************************************/
637 638
638void inline_speed 639void inline_speed
639upheap (WT *heap, int k) 640upheap (WT *heap, int k)
640{ 641{
641 WT w = heap [k]; 642 WT w = heap [k];
642 643
643 while (k && heap [k >> 1]->at > w->at) 644 while (k)
644 { 645 {
646 int p = (k - 1) >> 1;
647
648 if (heap [p]->at <= w->at)
649 break;
650
645 heap [k] = heap [k >> 1]; 651 heap [k] = heap [p];
646 ((W)heap [k])->active = k + 1; 652 ((W)heap [k])->active = k + 1;
647 k >>= 1; 653 k = p;
648 } 654 }
649 655
650 heap [k] = w; 656 heap [k] = w;
651 ((W)heap [k])->active = k + 1; 657 ((W)heap [k])->active = k + 1;
652
653} 658}
654 659
655void inline_speed 660void inline_speed
656downheap (WT *heap, int N, int k) 661downheap (WT *heap, int N, int k)
657{ 662{
658 WT w = heap [k]; 663 WT w = heap [k];
659 664
660 while (k < (N >> 1)) 665 for (;;)
661 { 666 {
662 int j = k << 1; 667 int c = (k << 1) + 1;
663 668
664 if (j + 1 < N && heap [j]->at > heap [j + 1]->at) 669 if (c >= N)
665 ++j;
666
667 if (w->at <= heap [j]->at)
668 break; 670 break;
669 671
672 c += c + 1 < N && heap [c]->at > heap [c + 1]->at
673 ? 1 : 0;
674
675 if (w->at <= heap [c]->at)
676 break;
677
670 heap [k] = heap [j]; 678 heap [k] = heap [c];
671 ((W)heap [k])->active = k + 1; 679 ((W)heap [k])->active = k + 1;
680
672 k = j; 681 k = c;
673 } 682 }
674 683
675 heap [k] = w; 684 heap [k] = w;
676 ((W)heap [k])->active = k + 1; 685 ((W)heap [k])->active = k + 1;
677} 686}
784 ev_unref (EV_A); /* child watcher should not keep loop alive */ 793 ev_unref (EV_A); /* child watcher should not keep loop alive */
785} 794}
786 795
787/*****************************************************************************/ 796/*****************************************************************************/
788 797
789static ev_child *childs [EV_PID_HASHSIZE]; 798static WL childs [EV_PID_HASHSIZE];
790 799
791#ifndef _WIN32 800#ifndef _WIN32
792 801
793static ev_signal childev; 802static ev_signal childev;
794 803
1206void inline_size 1215void inline_size
1207timers_reify (EV_P) 1216timers_reify (EV_P)
1208{ 1217{
1209 while (timercnt && ((WT)timers [0])->at <= mn_now) 1218 while (timercnt && ((WT)timers [0])->at <= mn_now)
1210 { 1219 {
1211 ev_timer *w = timers [0]; 1220 ev_timer *w = (ev_timer *)timers [0];
1212 1221
1213 /*assert (("inactive timer on timer heap detected", ev_is_active (w)));*/ 1222 /*assert (("inactive timer on timer heap detected", ev_is_active (w)));*/
1214 1223
1215 /* first reschedule or stop timer */ 1224 /* first reschedule or stop timer */
1216 if (w->repeat) 1225 if (w->repeat)
1219 1228
1220 ((WT)w)->at += w->repeat; 1229 ((WT)w)->at += w->repeat;
1221 if (((WT)w)->at < mn_now) 1230 if (((WT)w)->at < mn_now)
1222 ((WT)w)->at = mn_now; 1231 ((WT)w)->at = mn_now;
1223 1232
1224 downheap ((WT *)timers, timercnt, 0); 1233 downheap (timers, timercnt, 0);
1225 } 1234 }
1226 else 1235 else
1227 ev_timer_stop (EV_A_ w); /* nonrepeating: stop timer */ 1236 ev_timer_stop (EV_A_ w); /* nonrepeating: stop timer */
1228 1237
1229 ev_feed_event (EV_A_ (W)w, EV_TIMEOUT); 1238 ev_feed_event (EV_A_ (W)w, EV_TIMEOUT);
1234void inline_size 1243void inline_size
1235periodics_reify (EV_P) 1244periodics_reify (EV_P)
1236{ 1245{
1237 while (periodiccnt && ((WT)periodics [0])->at <= ev_rt_now) 1246 while (periodiccnt && ((WT)periodics [0])->at <= ev_rt_now)
1238 { 1247 {
1239 ev_periodic *w = periodics [0]; 1248 ev_periodic *w = (ev_periodic *)periodics [0];
1240 1249
1241 /*assert (("inactive timer on periodic heap detected", ev_is_active (w)));*/ 1250 /*assert (("inactive timer on periodic heap detected", ev_is_active (w)));*/
1242 1251
1243 /* first reschedule or stop timer */ 1252 /* first reschedule or stop timer */
1244 if (w->reschedule_cb) 1253 if (w->reschedule_cb)
1245 { 1254 {
1246 ((WT)w)->at = w->reschedule_cb (w, ev_rt_now + TIME_EPSILON); 1255 ((WT)w)->at = w->reschedule_cb (w, ev_rt_now + TIME_EPSILON);
1247 assert (("ev_periodic reschedule callback returned time in the past", ((WT)w)->at > ev_rt_now)); 1256 assert (("ev_periodic reschedule callback returned time in the past", ((WT)w)->at > ev_rt_now));
1248 downheap ((WT *)periodics, periodiccnt, 0); 1257 downheap (periodics, periodiccnt, 0);
1249 } 1258 }
1250 else if (w->interval) 1259 else if (w->interval)
1251 { 1260 {
1252 ((WT)w)->at = w->offset + ceil ((ev_rt_now - w->offset) / w->interval) * w->interval; 1261 ((WT)w)->at = w->offset + ceil ((ev_rt_now - w->offset) / w->interval) * w->interval;
1253 if (((WT)w)->at - ev_rt_now <= TIME_EPSILON) ((WT)w)->at += w->interval; 1262 if (((WT)w)->at - ev_rt_now <= TIME_EPSILON) ((WT)w)->at += w->interval;
1254 assert (("ev_periodic timeout in the past detected while processing timers, negative interval?", ((WT)w)->at > ev_rt_now)); 1263 assert (("ev_periodic timeout in the past detected while processing timers, negative interval?", ((WT)w)->at > ev_rt_now));
1255 downheap ((WT *)periodics, periodiccnt, 0); 1264 downheap (periodics, periodiccnt, 0);
1256 } 1265 }
1257 else 1266 else
1258 ev_periodic_stop (EV_A_ w); /* nonrepeating: stop timer */ 1267 ev_periodic_stop (EV_A_ w); /* nonrepeating: stop timer */
1259 1268
1260 ev_feed_event (EV_A_ (W)w, EV_PERIODIC); 1269 ev_feed_event (EV_A_ (W)w, EV_PERIODIC);
1267 int i; 1276 int i;
1268 1277
1269 /* adjust periodics after time jump */ 1278 /* adjust periodics after time jump */
1270 for (i = 0; i < periodiccnt; ++i) 1279 for (i = 0; i < periodiccnt; ++i)
1271 { 1280 {
1272 ev_periodic *w = periodics [i]; 1281 ev_periodic *w = (ev_periodic *)periodics [i];
1273 1282
1274 if (w->reschedule_cb) 1283 if (w->reschedule_cb)
1275 ((WT)w)->at = w->reschedule_cb (w, ev_rt_now); 1284 ((WT)w)->at = w->reschedule_cb (w, ev_rt_now);
1276 else if (w->interval) 1285 else if (w->interval)
1277 ((WT)w)->at = w->offset + ceil ((ev_rt_now - w->offset) / w->interval) * w->interval; 1286 ((WT)w)->at = w->offset + ceil ((ev_rt_now - w->offset) / w->interval) * w->interval;
1278 } 1287 }
1279 1288
1280 /* now rebuild the heap */ 1289 /* now rebuild the heap */
1281 for (i = periodiccnt >> 1; i--; ) 1290 for (i = periodiccnt >> 1; i--; )
1282 downheap ((WT *)periodics, periodiccnt, i); 1291 downheap (periodics, periodiccnt, i);
1283} 1292}
1284#endif 1293#endif
1285 1294
1286#if EV_IDLE_ENABLE 1295#if EV_IDLE_ENABLE
1287void inline_size 1296void inline_size
1304 } 1313 }
1305 } 1314 }
1306} 1315}
1307#endif 1316#endif
1308 1317
1309int inline_size 1318void inline_speed
1310time_update_monotonic (EV_P) 1319time_update (EV_P_ ev_tstamp max_block)
1311{ 1320{
1321 int i;
1322
1323#if EV_USE_MONOTONIC
1324 if (expect_true (have_monotonic))
1325 {
1326 ev_tstamp odiff = rtmn_diff;
1327
1312 mn_now = get_clock (); 1328 mn_now = get_clock ();
1313 1329
1330 /* only fetch the realtime clock every 0.5*MIN_TIMEJUMP seconds */
1331 /* interpolate in the meantime */
1314 if (expect_true (mn_now - now_floor < MIN_TIMEJUMP * .5)) 1332 if (expect_true (mn_now - now_floor < MIN_TIMEJUMP * .5))
1315 { 1333 {
1316 ev_rt_now = rtmn_diff + mn_now; 1334 ev_rt_now = rtmn_diff + mn_now;
1317 return 0; 1335 return;
1318 } 1336 }
1319 else 1337
1320 {
1321 now_floor = mn_now; 1338 now_floor = mn_now;
1322 ev_rt_now = ev_time (); 1339 ev_rt_now = ev_time ();
1323 return 1;
1324 }
1325}
1326 1340
1327void inline_size 1341 /* loop a few times, before making important decisions.
1328time_update (EV_P) 1342 * on the choice of "4": one iteration isn't enough,
1329{ 1343 * in case we get preempted during the calls to
1330 int i; 1344 * ev_time and get_clock. a second call is almost guaranteed
1331 1345 * to succeed in that case, though. and looping a few more times
1332#if EV_USE_MONOTONIC 1346 * doesn't hurt either as we only do this on time-jumps or
1333 if (expect_true (have_monotonic)) 1347 * in the unlikely event of having been preempted here.
1334 { 1348 */
1335 if (time_update_monotonic (EV_A)) 1349 for (i = 4; --i; )
1336 { 1350 {
1337 ev_tstamp odiff = rtmn_diff;
1338
1339 /* loop a few times, before making important decisions.
1340 * on the choice of "4": one iteration isn't enough,
1341 * in case we get preempted during the calls to
1342 * ev_time and get_clock. a second call is almost guaranteed
1343 * to succeed in that case, though. and looping a few more times
1344 * doesn't hurt either as we only do this on time-jumps or
1345 * in the unlikely event of having been preempted here.
1346 */
1347 for (i = 4; --i; )
1348 {
1349 rtmn_diff = ev_rt_now - mn_now; 1351 rtmn_diff = ev_rt_now - mn_now;
1350 1352
1351 if (fabs (odiff - rtmn_diff) < MIN_TIMEJUMP) 1353 if (fabs (odiff - rtmn_diff) < MIN_TIMEJUMP)
1352 return; /* all is well */ 1354 return; /* all is well */
1353 1355
1354 ev_rt_now = ev_time (); 1356 ev_rt_now = ev_time ();
1355 mn_now = get_clock (); 1357 mn_now = get_clock ();
1356 now_floor = mn_now; 1358 now_floor = mn_now;
1357 } 1359 }
1358 1360
1359# if EV_PERIODIC_ENABLE 1361# if EV_PERIODIC_ENABLE
1360 periodics_reschedule (EV_A); 1362 periodics_reschedule (EV_A);
1361# endif 1363# endif
1362 /* no timer adjustment, as the monotonic clock doesn't jump */ 1364 /* no timer adjustment, as the monotonic clock doesn't jump */
1363 /* timers_reschedule (EV_A_ rtmn_diff - odiff) */ 1365 /* timers_reschedule (EV_A_ rtmn_diff - odiff) */
1364 }
1365 } 1366 }
1366 else 1367 else
1367#endif 1368#endif
1368 { 1369 {
1369 ev_rt_now = ev_time (); 1370 ev_rt_now = ev_time ();
1370 1371
1371 if (expect_false (mn_now > ev_rt_now || mn_now < ev_rt_now - MAX_BLOCKTIME - MIN_TIMEJUMP)) 1372 if (expect_false (mn_now > ev_rt_now || ev_rt_now > mn_now + max_block + MIN_TIMEJUMP))
1372 { 1373 {
1373#if EV_PERIODIC_ENABLE 1374#if EV_PERIODIC_ENABLE
1374 periodics_reschedule (EV_A); 1375 periodics_reschedule (EV_A);
1375#endif 1376#endif
1376 /* adjust timers. this is easy, as the offset is the same for all of them */ 1377 /* adjust timers. this is easy, as the offset is the same for all of them */
1450 if (expect_false (flags & EVLOOP_NONBLOCK || idleall || !activecnt)) 1451 if (expect_false (flags & EVLOOP_NONBLOCK || idleall || !activecnt))
1451 block = 0.; /* do not block at all */ 1452 block = 0.; /* do not block at all */
1452 else 1453 else
1453 { 1454 {
1454 /* update time to cancel out callback processing overhead */ 1455 /* update time to cancel out callback processing overhead */
1455#if EV_USE_MONOTONIC
1456 if (expect_true (have_monotonic))
1457 time_update_monotonic (EV_A); 1456 time_update (EV_A_ 1e100);
1458 else
1459#endif
1460 {
1461 ev_rt_now = ev_time ();
1462 mn_now = ev_rt_now;
1463 }
1464 1457
1465 block = MAX_BLOCKTIME; 1458 block = MAX_BLOCKTIME;
1466 1459
1467 if (timercnt) 1460 if (timercnt)
1468 { 1461 {
1481 if (expect_false (block < 0.)) block = 0.; 1474 if (expect_false (block < 0.)) block = 0.;
1482 } 1475 }
1483 1476
1484 ++loop_count; 1477 ++loop_count;
1485 backend_poll (EV_A_ block); 1478 backend_poll (EV_A_ block);
1479
1480 /* update ev_rt_now, do magic */
1481 time_update (EV_A_ block);
1486 } 1482 }
1487
1488 /* update ev_rt_now, do magic */
1489 time_update (EV_A);
1490 1483
1491 /* queue pending timers and reschedule them */ 1484 /* queue pending timers and reschedule them */
1492 timers_reify (EV_A); /* relative timers called last */ 1485 timers_reify (EV_A); /* relative timers called last */
1493#if EV_PERIODIC_ENABLE 1486#if EV_PERIODIC_ENABLE
1494 periodics_reify (EV_A); /* absolute timers called first */ 1487 periodics_reify (EV_A); /* absolute timers called first */
1605 1598
1606 assert (("ev_io_start called with negative fd", fd >= 0)); 1599 assert (("ev_io_start called with negative fd", fd >= 0));
1607 1600
1608 ev_start (EV_A_ (W)w, 1); 1601 ev_start (EV_A_ (W)w, 1);
1609 array_needsize (ANFD, anfds, anfdmax, fd + 1, anfds_init); 1602 array_needsize (ANFD, anfds, anfdmax, fd + 1, anfds_init);
1610 wlist_add ((WL *)&anfds[fd].head, (WL)w); 1603 wlist_add (&anfds[fd].head, (WL)w);
1611 1604
1612 fd_change (EV_A_ fd); 1605 fd_change (EV_A_ fd, w->events & EV_IOFDSET);
1606 w->events &= ~ EV_IOFDSET;
1613} 1607}
1614 1608
1615void noinline 1609void noinline
1616ev_io_stop (EV_P_ ev_io *w) 1610ev_io_stop (EV_P_ ev_io *w)
1617{ 1611{
1619 if (expect_false (!ev_is_active (w))) 1613 if (expect_false (!ev_is_active (w)))
1620 return; 1614 return;
1621 1615
1622 assert (("ev_io_start called with illegal fd (must stay constant after start!)", w->fd >= 0 && w->fd < anfdmax)); 1616 assert (("ev_io_start called with illegal fd (must stay constant after start!)", w->fd >= 0 && w->fd < anfdmax));
1623 1617
1624 wlist_del ((WL *)&anfds[w->fd].head, (WL)w); 1618 wlist_del (&anfds[w->fd].head, (WL)w);
1625 ev_stop (EV_A_ (W)w); 1619 ev_stop (EV_A_ (W)w);
1626 1620
1627 fd_change (EV_A_ w->fd); 1621 fd_change (EV_A_ w->fd, 0);
1628} 1622}
1629 1623
1630void noinline 1624void noinline
1631ev_timer_start (EV_P_ ev_timer *w) 1625ev_timer_start (EV_P_ ev_timer *w)
1632{ 1626{
1636 ((WT)w)->at += mn_now; 1630 ((WT)w)->at += mn_now;
1637 1631
1638 assert (("ev_timer_start called with negative timer repeat value", w->repeat >= 0.)); 1632 assert (("ev_timer_start called with negative timer repeat value", w->repeat >= 0.));
1639 1633
1640 ev_start (EV_A_ (W)w, ++timercnt); 1634 ev_start (EV_A_ (W)w, ++timercnt);
1641 array_needsize (ev_timer *, timers, timermax, timercnt, EMPTY2); 1635 array_needsize (WT, timers, timermax, timercnt, EMPTY2);
1642 timers [timercnt - 1] = w; 1636 timers [timercnt - 1] = (WT)w;
1643 upheap ((WT *)timers, timercnt - 1); 1637 upheap (timers, timercnt - 1);
1644 1638
1645 /*assert (("internal timer heap corruption", timers [((W)w)->active - 1] == w));*/ 1639 /*assert (("internal timer heap corruption", timers [((W)w)->active - 1] == w));*/
1646} 1640}
1647 1641
1648void noinline 1642void noinline
1650{ 1644{
1651 clear_pending (EV_A_ (W)w); 1645 clear_pending (EV_A_ (W)w);
1652 if (expect_false (!ev_is_active (w))) 1646 if (expect_false (!ev_is_active (w)))
1653 return; 1647 return;
1654 1648
1655 assert (("internal timer heap corruption", timers [((W)w)->active - 1] == w)); 1649 assert (("internal timer heap corruption", timers [((W)w)->active - 1] == (WT)w));
1656 1650
1657 { 1651 {
1658 int active = ((W)w)->active; 1652 int active = ((W)w)->active;
1659 1653
1660 if (expect_true (--active < --timercnt)) 1654 if (expect_true (--active < --timercnt))
1661 { 1655 {
1662 timers [active] = timers [timercnt]; 1656 timers [active] = timers [timercnt];
1663 adjustheap ((WT *)timers, timercnt, active); 1657 adjustheap (timers, timercnt, active);
1664 } 1658 }
1665 } 1659 }
1666 1660
1667 ((WT)w)->at -= mn_now; 1661 ((WT)w)->at -= mn_now;
1668 1662
1675 if (ev_is_active (w)) 1669 if (ev_is_active (w))
1676 { 1670 {
1677 if (w->repeat) 1671 if (w->repeat)
1678 { 1672 {
1679 ((WT)w)->at = mn_now + w->repeat; 1673 ((WT)w)->at = mn_now + w->repeat;
1680 adjustheap ((WT *)timers, timercnt, ((W)w)->active - 1); 1674 adjustheap (timers, timercnt, ((W)w)->active - 1);
1681 } 1675 }
1682 else 1676 else
1683 ev_timer_stop (EV_A_ w); 1677 ev_timer_stop (EV_A_ w);
1684 } 1678 }
1685 else if (w->repeat) 1679 else if (w->repeat)
1706 } 1700 }
1707 else 1701 else
1708 ((WT)w)->at = w->offset; 1702 ((WT)w)->at = w->offset;
1709 1703
1710 ev_start (EV_A_ (W)w, ++periodiccnt); 1704 ev_start (EV_A_ (W)w, ++periodiccnt);
1711 array_needsize (ev_periodic *, periodics, periodicmax, periodiccnt, EMPTY2); 1705 array_needsize (WT, periodics, periodicmax, periodiccnt, EMPTY2);
1712 periodics [periodiccnt - 1] = w; 1706 periodics [periodiccnt - 1] = (WT)w;
1713 upheap ((WT *)periodics, periodiccnt - 1); 1707 upheap (periodics, periodiccnt - 1);
1714 1708
1715 /*assert (("internal periodic heap corruption", periodics [((W)w)->active - 1] == w));*/ 1709 /*assert (("internal periodic heap corruption", periodics [((W)w)->active - 1] == w));*/
1716} 1710}
1717 1711
1718void noinline 1712void noinline
1720{ 1714{
1721 clear_pending (EV_A_ (W)w); 1715 clear_pending (EV_A_ (W)w);
1722 if (expect_false (!ev_is_active (w))) 1716 if (expect_false (!ev_is_active (w)))
1723 return; 1717 return;
1724 1718
1725 assert (("internal periodic heap corruption", periodics [((W)w)->active - 1] == w)); 1719 assert (("internal periodic heap corruption", periodics [((W)w)->active - 1] == (WT)w));
1726 1720
1727 { 1721 {
1728 int active = ((W)w)->active; 1722 int active = ((W)w)->active;
1729 1723
1730 if (expect_true (--active < --periodiccnt)) 1724 if (expect_true (--active < --periodiccnt))
1731 { 1725 {
1732 periodics [active] = periodics [periodiccnt]; 1726 periodics [active] = periodics [periodiccnt];
1733 adjustheap ((WT *)periodics, periodiccnt, active); 1727 adjustheap (periodics, periodiccnt, active);
1734 } 1728 }
1735 } 1729 }
1736 1730
1737 ev_stop (EV_A_ (W)w); 1731 ev_stop (EV_A_ (W)w);
1738} 1732}
1759 if (expect_false (ev_is_active (w))) 1753 if (expect_false (ev_is_active (w)))
1760 return; 1754 return;
1761 1755
1762 assert (("ev_signal_start called with illegal signal number", w->signum > 0)); 1756 assert (("ev_signal_start called with illegal signal number", w->signum > 0));
1763 1757
1758 {
1759#ifndef _WIN32
1760 sigset_t full, prev;
1761 sigfillset (&full);
1762 sigprocmask (SIG_SETMASK, &full, &prev);
1763#endif
1764
1765 array_needsize (ANSIG, signals, signalmax, w->signum, signals_init);
1766
1767#ifndef _WIN32
1768 sigprocmask (SIG_SETMASK, &prev, 0);
1769#endif
1770 }
1771
1764 ev_start (EV_A_ (W)w, 1); 1772 ev_start (EV_A_ (W)w, 1);
1765 array_needsize (ANSIG, signals, signalmax, w->signum, signals_init);
1766 wlist_add ((WL *)&signals [w->signum - 1].head, (WL)w); 1773 wlist_add (&signals [w->signum - 1].head, (WL)w);
1767 1774
1768 if (!((WL)w)->next) 1775 if (!((WL)w)->next)
1769 { 1776 {
1770#if _WIN32 1777#if _WIN32
1771 signal (w->signum, sighandler); 1778 signal (w->signum, sighandler);
1784{ 1791{
1785 clear_pending (EV_A_ (W)w); 1792 clear_pending (EV_A_ (W)w);
1786 if (expect_false (!ev_is_active (w))) 1793 if (expect_false (!ev_is_active (w)))
1787 return; 1794 return;
1788 1795
1789 wlist_del ((WL *)&signals [w->signum - 1].head, (WL)w); 1796 wlist_del (&signals [w->signum - 1].head, (WL)w);
1790 ev_stop (EV_A_ (W)w); 1797 ev_stop (EV_A_ (W)w);
1791 1798
1792 if (!signals [w->signum - 1].head) 1799 if (!signals [w->signum - 1].head)
1793 signal (w->signum, SIG_DFL); 1800 signal (w->signum, SIG_DFL);
1794} 1801}
1801#endif 1808#endif
1802 if (expect_false (ev_is_active (w))) 1809 if (expect_false (ev_is_active (w)))
1803 return; 1810 return;
1804 1811
1805 ev_start (EV_A_ (W)w, 1); 1812 ev_start (EV_A_ (W)w, 1);
1806 wlist_add ((WL *)&childs [w->pid & (EV_PID_HASHSIZE - 1)], (WL)w); 1813 wlist_add (&childs [w->pid & (EV_PID_HASHSIZE - 1)], (WL)w);
1807} 1814}
1808 1815
1809void 1816void
1810ev_child_stop (EV_P_ ev_child *w) 1817ev_child_stop (EV_P_ ev_child *w)
1811{ 1818{
1812 clear_pending (EV_A_ (W)w); 1819 clear_pending (EV_A_ (W)w);
1813 if (expect_false (!ev_is_active (w))) 1820 if (expect_false (!ev_is_active (w)))
1814 return; 1821 return;
1815 1822
1816 wlist_del ((WL *)&childs [w->pid & (EV_PID_HASHSIZE - 1)], (WL)w); 1823 wlist_del (&childs [w->pid & (EV_PID_HASHSIZE - 1)], (WL)w);
1817 ev_stop (EV_A_ (W)w); 1824 ev_stop (EV_A_ (W)w);
1818} 1825}
1819 1826
1820#if EV_STAT_ENABLE 1827#if EV_STAT_ENABLE
1821 1828

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines