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

Comparing libev/ev.c (file contents):
Revision 1.357 by root, Sat Oct 23 22:25:44 2010 UTC vs.
Revision 1.362 by root, Sun Oct 24 19:15:52 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_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
1820inline_size void infy_fork (EV_P); 1849inline_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
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 */ 1918#endif /* multiplicity */
1901 1919
1902#if EV_VERIFY 1920#if EV_VERIFY
1903static void noinline 1921static void noinline
1904verify_watcher (EV_P_ W w) 1922verify_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
2006} 2029}
2007#endif 2030#endif
2008 2031
2009#if EV_MULTIPLICITY 2032#if EV_MULTIPLICITY
2010struct ev_loop * 2033struct ev_loop *
2011ev_default_loop_init (unsigned int flags)
2012#else 2034#else
2013int 2035int
2036#endif
2014ev_default_loop (unsigned int flags) 2037ev_default_loop (unsigned int flags)
2015#endif
2016{ 2038{
2017 if (!ev_default_loop_ptr) 2039 if (!ev_default_loop_ptr)
2018 { 2040 {
2019#if EV_MULTIPLICITY 2041#if EV_MULTIPLICITY
2020 EV_P = ev_default_loop_ptr = &default_loop_struct; 2042 EV_P = ev_default_loop_ptr = &default_loop_struct;
2039 2061
2040 return ev_default_loop_ptr; 2062 return ev_default_loop_ptr;
2041} 2063}
2042 2064
2043void 2065void
2044ev_default_destroy (void) 2066ev_loop_fork (EV_P)
2045{ 2067{
2046#if EV_MULTIPLICITY
2047 EV_P = ev_default_loop_ptr;
2048#endif
2049
2050 ev_default_loop_ptr = 0;
2051
2052#if EV_CHILD_ENABLE
2053 ev_ref (EV_A); /* child watcher */
2054 ev_signal_stop (EV_A_ &childev);
2055#endif
2056
2057 loop_destroy (EV_A);
2058}
2059
2060void
2061ev_default_fork (void)
2062{
2063#if EV_MULTIPLICITY
2064 EV_P = ev_default_loop_ptr;
2065#endif
2066
2067 postfork = 1; /* must be in line with ev_loop_fork */ 2068 postfork = 1; /* must be in line with ev_default_fork */
2068} 2069}
2069 2070
2070/*****************************************************************************/ 2071/*****************************************************************************/
2071 2072
2072void 2073void
3578 3579
3579 EV_FREQUENT_CHECK; 3580 EV_FREQUENT_CHECK;
3580} 3581}
3581#endif 3582#endif
3582 3583
3584#if EV_CLEANUP_ENABLE
3585void
3586ev_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 /* cleanup watchers should never keep a refcount on the loop */
3598 ev_unref (EV_A);
3599 EV_FREQUENT_CHECK;
3600}
3601
3602void
3603ev_cleanup_stop (EV_P_ ev_cleanup *w)
3604{
3605 clear_pending (EV_A_ (W)w);
3606 if (expect_false (!ev_is_active (w)))
3607 return;
3608
3609 EV_FREQUENT_CHECK;
3610 ev_ref (EV_A);
3611
3612 {
3613 int active = ev_active (w);
3614
3615 cleanups [active - 1] = cleanups [--cleanupcnt];
3616 ev_active (cleanups [active - 1]) = active;
3617 }
3618
3619 ev_stop (EV_A_ (W)w);
3620
3621 EV_FREQUENT_CHECK;
3622}
3623#endif
3624
3583#if EV_ASYNC_ENABLE 3625#if EV_ASYNC_ENABLE
3584void 3626void
3585ev_async_start (EV_P_ ev_async *w) 3627ev_async_start (EV_P_ ev_async *w)
3586{ 3628{
3587 if (expect_false (ev_is_active (w))) 3629 if (expect_false (ev_is_active (w)))

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines