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.360 by root, Sun Oct 24 18:12:41 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_CHILD_ENABLE
1742 if (ev_is_active (&childev))
1743 {
1744 ev_ref (EV_A); /* child watcher */
1745 ev_signal_stop (EV_A_ &childev);
1746 }
1747#endif
1740 1748
1741 if (ev_is_active (&pipe_w)) 1749 if (ev_is_active (&pipe_w))
1742 { 1750 {
1743 /*ev_ref (EV_A);*/ 1751 /*ev_ref (EV_A);*/
1744 /*ev_io_stop (EV_A_ &pipe_w);*/ 1752 /*ev_io_stop (EV_A_ &pipe_w);*/
1805 array_free (periodic, EMPTY); 1813 array_free (periodic, EMPTY);
1806#endif 1814#endif
1807#if EV_FORK_ENABLE 1815#if EV_FORK_ENABLE
1808 array_free (fork, EMPTY); 1816 array_free (fork, EMPTY);
1809#endif 1817#endif
1818#if EV_CLEANUP_ENABLE
1819 array_free (cleanup, EMPTY);
1820#endif
1810 array_free (prepare, EMPTY); 1821 array_free (prepare, EMPTY);
1811 array_free (check, EMPTY); 1822 array_free (check, EMPTY);
1812#if EV_ASYNC_ENABLE 1823#if EV_ASYNC_ENABLE
1813 array_free (async, EMPTY); 1824 array_free (async, EMPTY);
1814#endif 1825#endif
1815 1826
1816 backend = 0; 1827 backend = 0;
1828
1829#if EV_MULTIPLICITY
1830 if (ev_is_default_loop (EV_A))
1831#endif
1832 ev_default_loop_ptr = 0;
1833#if EV_MULTIPLICITY
1834 else
1835 ev_free (EV_A);
1836#endif
1817} 1837}
1818 1838
1819#if EV_USE_INOTIFY 1839#if EV_USE_INOTIFY
1820inline_size void infy_fork (EV_P); 1840inline_size void infy_fork (EV_P);
1821#endif 1841#endif
1880 loop_init (EV_A_ flags); 1900 loop_init (EV_A_ flags);
1881 1901
1882 if (ev_backend (EV_A)) 1902 if (ev_backend (EV_A))
1883 return EV_A; 1903 return EV_A;
1884 1904
1905 ev_free (EV_A);
1885 return 0; 1906 return 0;
1886} 1907}
1887 1908
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 */ 1909#endif /* multiplicity */
1901 1910
1902#if EV_VERIFY 1911#if EV_VERIFY
1903static void noinline 1912static void noinline
1904verify_watcher (EV_P_ W w) 1913verify_watcher (EV_P_ W w)
1979#if EV_FORK_ENABLE 1988#if EV_FORK_ENABLE
1980 assert (forkmax >= forkcnt); 1989 assert (forkmax >= forkcnt);
1981 array_verify (EV_A_ (W *)forks, forkcnt); 1990 array_verify (EV_A_ (W *)forks, forkcnt);
1982#endif 1991#endif
1983 1992
1993#if EV_CLEANUP_ENABLE
1994 assert (cleanupmax >= cleanupcnt);
1995 array_verify (EV_A_ (W *)cleanups, cleanupcnt);
1996#endif
1997
1984#if EV_ASYNC_ENABLE 1998#if EV_ASYNC_ENABLE
1985 assert (asyncmax >= asynccnt); 1999 assert (asyncmax >= asynccnt);
1986 array_verify (EV_A_ (W *)asyncs, asynccnt); 2000 array_verify (EV_A_ (W *)asyncs, asynccnt);
1987#endif 2001#endif
1988 2002
2006} 2020}
2007#endif 2021#endif
2008 2022
2009#if EV_MULTIPLICITY 2023#if EV_MULTIPLICITY
2010struct ev_loop * 2024struct ev_loop *
2011ev_default_loop_init (unsigned int flags)
2012#else 2025#else
2013int 2026int
2027#endif
2014ev_default_loop (unsigned int flags) 2028ev_default_loop (unsigned int flags)
2015#endif
2016{ 2029{
2017 if (!ev_default_loop_ptr) 2030 if (!ev_default_loop_ptr)
2018 { 2031 {
2019#if EV_MULTIPLICITY 2032#if EV_MULTIPLICITY
2020 EV_P = ev_default_loop_ptr = &default_loop_struct; 2033 EV_P = ev_default_loop_ptr = &default_loop_struct;
2039 2052
2040 return ev_default_loop_ptr; 2053 return ev_default_loop_ptr;
2041} 2054}
2042 2055
2043void 2056void
2044ev_default_destroy (void) 2057ev_loop_fork (EV_P)
2045{ 2058{
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 */ 2059 postfork = 1; /* must be in line with ev_default_fork */
2068} 2060}
2069 2061
2070/*****************************************************************************/ 2062/*****************************************************************************/
2071 2063
2072void 2064void
3578 3570
3579 EV_FREQUENT_CHECK; 3571 EV_FREQUENT_CHECK;
3580} 3572}
3581#endif 3573#endif
3582 3574
3575#if EV_CLEANUP_ENABLE
3576void
3577ev_cleanup_start (EV_P_ ev_cleanup *w)
3578{
3579 if (expect_false (ev_is_active (w)))
3580 return;
3581
3582 EV_FREQUENT_CHECK;
3583
3584 ev_start (EV_A_ (W)w, ++cleanupcnt);
3585 array_needsize (ev_cleanup *, cleanups, cleanupmax, cleanupcnt, EMPTY2);
3586 cleanups [cleanupcnt - 1] = w;
3587
3588 EV_FREQUENT_CHECK;
3589}
3590
3591void
3592ev_cleanup_stop (EV_P_ ev_cleanup *w)
3593{
3594 clear_pending (EV_A_ (W)w);
3595 if (expect_false (!ev_is_active (w)))
3596 return;
3597
3598 EV_FREQUENT_CHECK;
3599
3600 {
3601 int active = ev_active (w);
3602
3603 cleanups [active - 1] = cleanups [--cleanupcnt];
3604 ev_active (cleanups [active - 1]) = active;
3605 }
3606
3607 ev_stop (EV_A_ (W)w);
3608
3609 EV_FREQUENT_CHECK;
3610}
3611#endif
3612
3583#if EV_ASYNC_ENABLE 3613#if EV_ASYNC_ENABLE
3584void 3614void
3585ev_async_start (EV_P_ ev_async *w) 3615ev_async_start (EV_P_ ev_async *w)
3586{ 3616{
3587 if (expect_false (ev_is_active (w))) 3617 if (expect_false (ev_is_active (w)))

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines