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

Comparing libev/ev.c (file contents):
Revision 1.358 by root, Sun Oct 24 14:44:40 2010 UTC vs.
Revision 1.364 by root, Sun Oct 24 21:51:03 2010 UTC

530 530
531static unsigned int noinline 531static unsigned int noinline
532ev_linux_version (void) 532ev_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 */
1736static void noinline 1736void
1737loop_destroy (EV_P) 1737ev_loop_destroy (EV_P)
1738{ 1738{
1739 int i; 1739 int i;
1740
1741#if EV_MULTIPLICITY
1742 /* mimic free (0) */
1743 if (!EV_A)
1744 return;
1745#endif
1746
1747#if EV_CLEANUP_ENABLE
1748 /* queue cleanup watchers (and execute them) */
1749 if (expect_false (cleanupcnt))
1750 {
1751 queue_events (EV_A_ (W *)cleanups, cleanupcnt, EV_CLEANUP);
1752 EV_INVOKE_PENDING;
1753 }
1754#endif
1755
1756#if EV_CHILD_ENABLE
1757 if (ev_is_active (&childev))
1758 {
1759 ev_ref (EV_A); /* child watcher */
1760 ev_signal_stop (EV_A_ &childev);
1761 }
1762#endif
1740 1763
1741 if (ev_is_active (&pipe_w)) 1764 if (ev_is_active (&pipe_w))
1742 { 1765 {
1743 /*ev_ref (EV_A);*/ 1766 /*ev_ref (EV_A);*/
1744 /*ev_io_stop (EV_A_ &pipe_w);*/ 1767 /*ev_io_stop (EV_A_ &pipe_w);*/
1805 array_free (periodic, EMPTY); 1828 array_free (periodic, EMPTY);
1806#endif 1829#endif
1807#if EV_FORK_ENABLE 1830#if EV_FORK_ENABLE
1808 array_free (fork, EMPTY); 1831 array_free (fork, EMPTY);
1809#endif 1832#endif
1833#if EV_CLEANUP_ENABLE
1834 array_free (cleanup, EMPTY);
1835#endif
1810 array_free (prepare, EMPTY); 1836 array_free (prepare, EMPTY);
1811 array_free (check, EMPTY); 1837 array_free (check, EMPTY);
1812#if EV_ASYNC_ENABLE 1838#if EV_ASYNC_ENABLE
1813 array_free (async, EMPTY); 1839 array_free (async, EMPTY);
1814#endif 1840#endif
1815 1841
1816 backend = 0; 1842 backend = 0;
1843
1844#if EV_MULTIPLICITY
1845 if (ev_is_default_loop (EV_A))
1846#endif
1847 ev_default_loop_ptr = 0;
1848#if EV_MULTIPLICITY
1849 else
1850 ev_free (EV_A);
1851#endif
1817} 1852}
1818 1853
1819#if EV_USE_INOTIFY 1854#if EV_USE_INOTIFY
1820inline_size void infy_fork (EV_P); 1855inline_size void infy_fork (EV_P);
1821#endif 1856#endif
1880 loop_init (EV_A_ flags); 1915 loop_init (EV_A_ flags);
1881 1916
1882 if (ev_backend (EV_A)) 1917 if (ev_backend (EV_A))
1883 return EV_A; 1918 return EV_A;
1884 1919
1920 ev_free (EV_A);
1885 return 0; 1921 return 0;
1886} 1922}
1887 1923
1888void
1889ev_loop_destroy (EV_P)
1890{
1891 loop_destroy (EV_A);
1892 ev_free (loop);
1893}
1894
1895void
1896ev_loop_fork (EV_P)
1897{
1898 postfork = 1; /* must be in line with ev_default_fork */
1899}
1900#endif /* multiplicity */ 1924#endif /* multiplicity */
1901 1925
1902#if EV_VERIFY 1926#if EV_VERIFY
1903static void noinline 1927static void noinline
1904verify_watcher (EV_P_ W w) 1928verify_watcher (EV_P_ W w)
1979#if EV_FORK_ENABLE 2003#if EV_FORK_ENABLE
1980 assert (forkmax >= forkcnt); 2004 assert (forkmax >= forkcnt);
1981 array_verify (EV_A_ (W *)forks, forkcnt); 2005 array_verify (EV_A_ (W *)forks, forkcnt);
1982#endif 2006#endif
1983 2007
2008#if EV_CLEANUP_ENABLE
2009 assert (cleanupmax >= cleanupcnt);
2010 array_verify (EV_A_ (W *)cleanups, cleanupcnt);
2011#endif
2012
1984#if EV_ASYNC_ENABLE 2013#if EV_ASYNC_ENABLE
1985 assert (asyncmax >= asynccnt); 2014 assert (asyncmax >= asynccnt);
1986 array_verify (EV_A_ (W *)asyncs, asynccnt); 2015 array_verify (EV_A_ (W *)asyncs, asynccnt);
1987#endif 2016#endif
1988 2017
2038 2067
2039 return ev_default_loop_ptr; 2068 return ev_default_loop_ptr;
2040} 2069}
2041 2070
2042void 2071void
2043ev_default_destroy (void) 2072ev_loop_fork (EV_P)
2044{ 2073{
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
2059void
2060ev_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 */ 2074 postfork = 1; /* must be in line with ev_default_fork */
2067} 2075}
2068 2076
2069/*****************************************************************************/ 2077/*****************************************************************************/
2070 2078
2071void 2079void
3577 3585
3578 EV_FREQUENT_CHECK; 3586 EV_FREQUENT_CHECK;
3579} 3587}
3580#endif 3588#endif
3581 3589
3590#if EV_CLEANUP_ENABLE
3591void
3592ev_cleanup_start (EV_P_ ev_cleanup *w)
3593{
3594 if (expect_false (ev_is_active (w)))
3595 return;
3596
3597 EV_FREQUENT_CHECK;
3598
3599 ev_start (EV_A_ (W)w, ++cleanupcnt);
3600 array_needsize (ev_cleanup *, cleanups, cleanupmax, cleanupcnt, EMPTY2);
3601 cleanups [cleanupcnt - 1] = w;
3602
3603 /* cleanup watchers should never keep a refcount on the loop */
3604 ev_unref (EV_A);
3605 EV_FREQUENT_CHECK;
3606}
3607
3608void
3609ev_cleanup_stop (EV_P_ ev_cleanup *w)
3610{
3611 clear_pending (EV_A_ (W)w);
3612 if (expect_false (!ev_is_active (w)))
3613 return;
3614
3615 EV_FREQUENT_CHECK;
3616 ev_ref (EV_A);
3617
3618 {
3619 int active = ev_active (w);
3620
3621 cleanups [active - 1] = cleanups [--cleanupcnt];
3622 ev_active (cleanups [active - 1]) = active;
3623 }
3624
3625 ev_stop (EV_A_ (W)w);
3626
3627 EV_FREQUENT_CHECK;
3628}
3629#endif
3630
3582#if EV_ASYNC_ENABLE 3631#if EV_ASYNC_ENABLE
3583void 3632void
3584ev_async_start (EV_P_ ev_async *w) 3633ev_async_start (EV_P_ ev_async *w)
3585{ 3634{
3586 if (expect_false (ev_is_active (w))) 3635 if (expect_false (ev_is_active (w)))

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines