… | |
… | |
557 | |
557 | |
558 | fdchangecnt = 0; |
558 | fdchangecnt = 0; |
559 | } |
559 | } |
560 | |
560 | |
561 | void inline_size |
561 | void inline_size |
562 | fd_change (EV_P_ int fd) |
562 | fd_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 | |
574 | void inline_speed |
575 | void inline_speed |
575 | fd_kill (EV_P_ int fd) |
576 | fd_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 | |
… | |
… | |
792 | ev_unref (EV_A); /* child watcher should not keep loop alive */ |
793 | ev_unref (EV_A); /* child watcher should not keep loop alive */ |
793 | } |
794 | } |
794 | |
795 | |
795 | /*****************************************************************************/ |
796 | /*****************************************************************************/ |
796 | |
797 | |
797 | static ev_child *childs [EV_PID_HASHSIZE]; |
798 | static WL childs [EV_PID_HASHSIZE]; |
798 | |
799 | |
799 | #ifndef _WIN32 |
800 | #ifndef _WIN32 |
800 | |
801 | |
801 | static ev_signal childev; |
802 | static ev_signal childev; |
802 | |
803 | |
… | |
… | |
1597 | |
1598 | |
1598 | assert (("ev_io_start called with negative fd", fd >= 0)); |
1599 | assert (("ev_io_start called with negative fd", fd >= 0)); |
1599 | |
1600 | |
1600 | ev_start (EV_A_ (W)w, 1); |
1601 | ev_start (EV_A_ (W)w, 1); |
1601 | array_needsize (ANFD, anfds, anfdmax, fd + 1, anfds_init); |
1602 | array_needsize (ANFD, anfds, anfdmax, fd + 1, anfds_init); |
1602 | wlist_add ((WL *)&anfds[fd].head, (WL)w); |
1603 | wlist_add (&anfds[fd].head, (WL)w); |
1603 | |
1604 | |
1604 | fd_change (EV_A_ fd); |
1605 | fd_change (EV_A_ fd, w->events & EV_IOFDSET); |
|
|
1606 | w->events &= ~ EV_IOFDSET; |
1605 | } |
1607 | } |
1606 | |
1608 | |
1607 | void noinline |
1609 | void noinline |
1608 | ev_io_stop (EV_P_ ev_io *w) |
1610 | ev_io_stop (EV_P_ ev_io *w) |
1609 | { |
1611 | { |
… | |
… | |
1611 | if (expect_false (!ev_is_active (w))) |
1613 | if (expect_false (!ev_is_active (w))) |
1612 | return; |
1614 | return; |
1613 | |
1615 | |
1614 | 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)); |
1615 | |
1617 | |
1616 | wlist_del ((WL *)&anfds[w->fd].head, (WL)w); |
1618 | wlist_del (&anfds[w->fd].head, (WL)w); |
1617 | ev_stop (EV_A_ (W)w); |
1619 | ev_stop (EV_A_ (W)w); |
1618 | |
1620 | |
1619 | fd_change (EV_A_ w->fd); |
1621 | fd_change (EV_A_ w->fd, 0); |
1620 | } |
1622 | } |
1621 | |
1623 | |
1622 | void noinline |
1624 | void noinline |
1623 | ev_timer_start (EV_P_ ev_timer *w) |
1625 | ev_timer_start (EV_P_ ev_timer *w) |
1624 | { |
1626 | { |
… | |
… | |
1766 | sigprocmask (SIG_SETMASK, &prev, 0); |
1768 | sigprocmask (SIG_SETMASK, &prev, 0); |
1767 | #endif |
1769 | #endif |
1768 | } |
1770 | } |
1769 | |
1771 | |
1770 | ev_start (EV_A_ (W)w, 1); |
1772 | ev_start (EV_A_ (W)w, 1); |
1771 | wlist_add ((WL *)&signals [w->signum - 1].head, (WL)w); |
1773 | wlist_add (&signals [w->signum - 1].head, (WL)w); |
1772 | |
1774 | |
1773 | if (!((WL)w)->next) |
1775 | if (!((WL)w)->next) |
1774 | { |
1776 | { |
1775 | #if _WIN32 |
1777 | #if _WIN32 |
1776 | signal (w->signum, sighandler); |
1778 | signal (w->signum, sighandler); |
… | |
… | |
1789 | { |
1791 | { |
1790 | clear_pending (EV_A_ (W)w); |
1792 | clear_pending (EV_A_ (W)w); |
1791 | if (expect_false (!ev_is_active (w))) |
1793 | if (expect_false (!ev_is_active (w))) |
1792 | return; |
1794 | return; |
1793 | |
1795 | |
1794 | wlist_del ((WL *)&signals [w->signum - 1].head, (WL)w); |
1796 | wlist_del (&signals [w->signum - 1].head, (WL)w); |
1795 | ev_stop (EV_A_ (W)w); |
1797 | ev_stop (EV_A_ (W)w); |
1796 | |
1798 | |
1797 | if (!signals [w->signum - 1].head) |
1799 | if (!signals [w->signum - 1].head) |
1798 | signal (w->signum, SIG_DFL); |
1800 | signal (w->signum, SIG_DFL); |
1799 | } |
1801 | } |
… | |
… | |
1806 | #endif |
1808 | #endif |
1807 | if (expect_false (ev_is_active (w))) |
1809 | if (expect_false (ev_is_active (w))) |
1808 | return; |
1810 | return; |
1809 | |
1811 | |
1810 | ev_start (EV_A_ (W)w, 1); |
1812 | ev_start (EV_A_ (W)w, 1); |
1811 | wlist_add ((WL *)&childs [w->pid & (EV_PID_HASHSIZE - 1)], (WL)w); |
1813 | wlist_add (&childs [w->pid & (EV_PID_HASHSIZE - 1)], (WL)w); |
1812 | } |
1814 | } |
1813 | |
1815 | |
1814 | void |
1816 | void |
1815 | ev_child_stop (EV_P_ ev_child *w) |
1817 | ev_child_stop (EV_P_ ev_child *w) |
1816 | { |
1818 | { |
1817 | clear_pending (EV_A_ (W)w); |
1819 | clear_pending (EV_A_ (W)w); |
1818 | if (expect_false (!ev_is_active (w))) |
1820 | if (expect_false (!ev_is_active (w))) |
1819 | return; |
1821 | return; |
1820 | |
1822 | |
1821 | wlist_del ((WL *)&childs [w->pid & (EV_PID_HASHSIZE - 1)], (WL)w); |
1823 | wlist_del (&childs [w->pid & (EV_PID_HASHSIZE - 1)], (WL)w); |
1822 | ev_stop (EV_A_ (W)w); |
1824 | ev_stop (EV_A_ (W)w); |
1823 | } |
1825 | } |
1824 | |
1826 | |
1825 | #if EV_STAT_ENABLE |
1827 | #if EV_STAT_ENABLE |
1826 | |
1828 | |