… | |
… | |
530 | |
530 | |
531 | static unsigned int noinline |
531 | static unsigned int noinline |
532 | ev_linux_version (void) |
532 | ev_linux_version (void) |
533 | { |
533 | { |
534 | #ifdef __linux |
534 | #ifdef __linux |
|
|
535 | unsigned int v = 0; |
535 | struct utsname buf; |
536 | struct utsname buf; |
536 | unsigned int v; |
|
|
537 | int i; |
537 | int i; |
538 | char *p = buf.release; |
538 | char *p = buf.release; |
539 | |
539 | |
540 | if (uname (&buf)) |
540 | if (uname (&buf)) |
541 | return 0; |
541 | return 0; |
… | |
… | |
1731 | #endif |
1731 | #endif |
1732 | } |
1732 | } |
1733 | } |
1733 | } |
1734 | |
1734 | |
1735 | /* free up a loop structure */ |
1735 | /* free up a loop structure */ |
1736 | static void noinline |
1736 | void |
1737 | loop_destroy (EV_P) |
1737 | ev_loop_destroy (EV_P) |
1738 | { |
1738 | { |
1739 | int i; |
1739 | int i; |
|
|
1740 | |
|
|
1741 | #if EV_CLEANUP_ENABLE |
|
|
1742 | /* queue cleanup watchers (and execute them) */ |
|
|
1743 | if (expect_false (cleanupcnt)) |
|
|
1744 | { |
|
|
1745 | queue_events (EV_A_ (W *)cleanups, cleanupcnt, EV_CLEANUP); |
|
|
1746 | EV_INVOKE_PENDING; |
|
|
1747 | } |
|
|
1748 | #endif |
|
|
1749 | |
|
|
1750 | #if EV_CHILD_ENABLE |
|
|
1751 | if (ev_is_active (&childev)) |
|
|
1752 | { |
|
|
1753 | ev_ref (EV_A); /* child watcher */ |
|
|
1754 | ev_signal_stop (EV_A_ &childev); |
|
|
1755 | } |
|
|
1756 | #endif |
1740 | |
1757 | |
1741 | if (ev_is_active (&pipe_w)) |
1758 | if (ev_is_active (&pipe_w)) |
1742 | { |
1759 | { |
1743 | /*ev_ref (EV_A);*/ |
1760 | /*ev_ref (EV_A);*/ |
1744 | /*ev_io_stop (EV_A_ &pipe_w);*/ |
1761 | /*ev_io_stop (EV_A_ &pipe_w);*/ |
… | |
… | |
1805 | array_free (periodic, EMPTY); |
1822 | array_free (periodic, EMPTY); |
1806 | #endif |
1823 | #endif |
1807 | #if EV_FORK_ENABLE |
1824 | #if EV_FORK_ENABLE |
1808 | array_free (fork, EMPTY); |
1825 | array_free (fork, EMPTY); |
1809 | #endif |
1826 | #endif |
|
|
1827 | #if EV_CLEANUP_ENABLE |
|
|
1828 | array_free (cleanup, EMPTY); |
|
|
1829 | #endif |
1810 | array_free (prepare, EMPTY); |
1830 | array_free (prepare, EMPTY); |
1811 | array_free (check, EMPTY); |
1831 | array_free (check, EMPTY); |
1812 | #if EV_ASYNC_ENABLE |
1832 | #if EV_ASYNC_ENABLE |
1813 | array_free (async, EMPTY); |
1833 | array_free (async, EMPTY); |
1814 | #endif |
1834 | #endif |
1815 | |
1835 | |
1816 | backend = 0; |
1836 | backend = 0; |
|
|
1837 | |
|
|
1838 | #if EV_MULTIPLICITY |
|
|
1839 | if (ev_is_default_loop (EV_A)) |
|
|
1840 | #endif |
|
|
1841 | ev_default_loop_ptr = 0; |
|
|
1842 | #if EV_MULTIPLICITY |
|
|
1843 | else |
|
|
1844 | ev_free (EV_A); |
|
|
1845 | #endif |
1817 | } |
1846 | } |
1818 | |
1847 | |
1819 | #if EV_USE_INOTIFY |
1848 | #if EV_USE_INOTIFY |
1820 | inline_size void infy_fork (EV_P); |
1849 | inline_size void infy_fork (EV_P); |
1821 | #endif |
1850 | #endif |
… | |
… | |
1880 | loop_init (EV_A_ flags); |
1909 | loop_init (EV_A_ flags); |
1881 | |
1910 | |
1882 | if (ev_backend (EV_A)) |
1911 | if (ev_backend (EV_A)) |
1883 | return EV_A; |
1912 | return EV_A; |
1884 | |
1913 | |
|
|
1914 | ev_free (EV_A); |
1885 | return 0; |
1915 | return 0; |
1886 | } |
1916 | } |
1887 | |
1917 | |
1888 | void |
|
|
1889 | ev_loop_destroy (EV_P) |
|
|
1890 | { |
|
|
1891 | loop_destroy (EV_A); |
|
|
1892 | ev_free (loop); |
|
|
1893 | } |
|
|
1894 | |
|
|
1895 | void |
|
|
1896 | ev_loop_fork (EV_P) |
|
|
1897 | { |
|
|
1898 | postfork = 1; /* must be in line with ev_default_fork */ |
|
|
1899 | } |
|
|
1900 | #endif /* multiplicity */ |
1918 | #endif /* multiplicity */ |
1901 | |
1919 | |
1902 | #if EV_VERIFY |
1920 | #if EV_VERIFY |
1903 | static void noinline |
1921 | static void noinline |
1904 | verify_watcher (EV_P_ W w) |
1922 | verify_watcher (EV_P_ W w) |
… | |
… | |
1979 | #if EV_FORK_ENABLE |
1997 | #if EV_FORK_ENABLE |
1980 | assert (forkmax >= forkcnt); |
1998 | assert (forkmax >= forkcnt); |
1981 | array_verify (EV_A_ (W *)forks, forkcnt); |
1999 | array_verify (EV_A_ (W *)forks, forkcnt); |
1982 | #endif |
2000 | #endif |
1983 | |
2001 | |
|
|
2002 | #if EV_CLEANUP_ENABLE |
|
|
2003 | assert (cleanupmax >= cleanupcnt); |
|
|
2004 | array_verify (EV_A_ (W *)cleanups, cleanupcnt); |
|
|
2005 | #endif |
|
|
2006 | |
1984 | #if EV_ASYNC_ENABLE |
2007 | #if EV_ASYNC_ENABLE |
1985 | assert (asyncmax >= asynccnt); |
2008 | assert (asyncmax >= asynccnt); |
1986 | array_verify (EV_A_ (W *)asyncs, asynccnt); |
2009 | array_verify (EV_A_ (W *)asyncs, asynccnt); |
1987 | #endif |
2010 | #endif |
1988 | |
2011 | |
… | |
… | |
2038 | |
2061 | |
2039 | return ev_default_loop_ptr; |
2062 | return ev_default_loop_ptr; |
2040 | } |
2063 | } |
2041 | |
2064 | |
2042 | void |
2065 | void |
2043 | ev_default_destroy (void) |
2066 | ev_loop_fork (EV_P) |
2044 | { |
2067 | { |
2045 | #if EV_MULTIPLICITY |
|
|
2046 | EV_P = ev_default_loop_ptr; |
|
|
2047 | #endif |
|
|
2048 | |
|
|
2049 | ev_default_loop_ptr = 0; |
|
|
2050 | |
|
|
2051 | #if EV_CHILD_ENABLE |
|
|
2052 | ev_ref (EV_A); /* child watcher */ |
|
|
2053 | ev_signal_stop (EV_A_ &childev); |
|
|
2054 | #endif |
|
|
2055 | |
|
|
2056 | loop_destroy (EV_A); |
|
|
2057 | } |
|
|
2058 | |
|
|
2059 | void |
|
|
2060 | ev_default_fork (void) |
|
|
2061 | { |
|
|
2062 | #if EV_MULTIPLICITY |
|
|
2063 | EV_P = ev_default_loop_ptr; |
|
|
2064 | #endif |
|
|
2065 | |
|
|
2066 | postfork = 1; /* must be in line with ev_loop_fork */ |
2068 | postfork = 1; /* must be in line with ev_default_fork */ |
2067 | } |
2069 | } |
2068 | |
2070 | |
2069 | /*****************************************************************************/ |
2071 | /*****************************************************************************/ |
2070 | |
2072 | |
2071 | void |
2073 | void |
… | |
… | |
3577 | |
3579 | |
3578 | EV_FREQUENT_CHECK; |
3580 | EV_FREQUENT_CHECK; |
3579 | } |
3581 | } |
3580 | #endif |
3582 | #endif |
3581 | |
3583 | |
|
|
3584 | #if EV_CLEANUP_ENABLE |
|
|
3585 | void |
|
|
3586 | ev_cleanup_start (EV_P_ ev_cleanup *w) |
|
|
3587 | { |
|
|
3588 | if (expect_false (ev_is_active (w))) |
|
|
3589 | return; |
|
|
3590 | |
|
|
3591 | EV_FREQUENT_CHECK; |
|
|
3592 | |
|
|
3593 | ev_start (EV_A_ (W)w, ++cleanupcnt); |
|
|
3594 | array_needsize (ev_cleanup *, cleanups, cleanupmax, cleanupcnt, EMPTY2); |
|
|
3595 | cleanups [cleanupcnt - 1] = w; |
|
|
3596 | |
|
|
3597 | EV_FREQUENT_CHECK; |
|
|
3598 | } |
|
|
3599 | |
|
|
3600 | void |
|
|
3601 | ev_cleanup_stop (EV_P_ ev_cleanup *w) |
|
|
3602 | { |
|
|
3603 | clear_pending (EV_A_ (W)w); |
|
|
3604 | if (expect_false (!ev_is_active (w))) |
|
|
3605 | return; |
|
|
3606 | |
|
|
3607 | EV_FREQUENT_CHECK; |
|
|
3608 | |
|
|
3609 | { |
|
|
3610 | int active = ev_active (w); |
|
|
3611 | |
|
|
3612 | cleanups [active - 1] = cleanups [--cleanupcnt]; |
|
|
3613 | ev_active (cleanups [active - 1]) = active; |
|
|
3614 | } |
|
|
3615 | |
|
|
3616 | ev_stop (EV_A_ (W)w); |
|
|
3617 | |
|
|
3618 | EV_FREQUENT_CHECK; |
|
|
3619 | } |
|
|
3620 | #endif |
|
|
3621 | |
3582 | #if EV_ASYNC_ENABLE |
3622 | #if EV_ASYNC_ENABLE |
3583 | void |
3623 | void |
3584 | ev_async_start (EV_P_ ev_async *w) |
3624 | ev_async_start (EV_P_ ev_async *w) |
3585 | { |
3625 | { |
3586 | if (expect_false (ev_is_active (w))) |
3626 | if (expect_false (ev_is_active (w))) |