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

Comparing libev/ev.c (file contents):
Revision 1.423 by root, Sun Apr 22 10:14:20 2012 UTC vs.
Revision 1.426 by root, Sun May 6 13:42:10 2012 UTC

1430 w_->pending = ++pendingcnt [pri]; 1430 w_->pending = ++pendingcnt [pri];
1431 array_needsize (ANPENDING, pendings [pri], pendingmax [pri], w_->pending, EMPTY2); 1431 array_needsize (ANPENDING, pendings [pri], pendingmax [pri], w_->pending, EMPTY2);
1432 pendings [pri][w_->pending - 1].w = w_; 1432 pendings [pri][w_->pending - 1].w = w_;
1433 pendings [pri][w_->pending - 1].events = revents; 1433 pendings [pri][w_->pending - 1].events = revents;
1434 } 1434 }
1435
1436 pendingpri = NUMPRI - 1;
1435} 1437}
1436 1438
1437inline_speed void 1439inline_speed void
1438feed_reverse (EV_P_ W w) 1440feed_reverse (EV_P_ W w)
1439{ 1441{
1844} 1846}
1845 1847
1846inline_speed void 1848inline_speed void
1847evpipe_write (EV_P_ EV_ATOMIC_T *flag) 1849evpipe_write (EV_P_ EV_ATOMIC_T *flag)
1848{ 1850{
1851 ECB_MEMORY_FENCE; /* push out the write before this function was called, acquire flag */
1852
1849 if (expect_true (*flag)) 1853 if (expect_true (*flag))
1850 return; 1854 return;
1851 1855
1852 *flag = 1; 1856 *flag = 1;
1853 1857
1912 } 1916 }
1913 } 1917 }
1914 1918
1915 pipe_write_skipped = 0; 1919 pipe_write_skipped = 0;
1916 1920
1921 ECB_MEMORY_FENCE; /* push out skipped, acquire flags */
1922
1917#if EV_SIGNAL_ENABLE 1923#if EV_SIGNAL_ENABLE
1918 if (sig_pending) 1924 if (sig_pending)
1919 { 1925 {
1920 sig_pending = 0; 1926 sig_pending = 0;
1927
1928 ECB_MEMORY_FENCE_RELEASE;
1921 1929
1922 for (i = EV_NSIG - 1; i--; ) 1930 for (i = EV_NSIG - 1; i--; )
1923 if (expect_false (signals [i].pending)) 1931 if (expect_false (signals [i].pending))
1924 ev_feed_signal_event (EV_A_ i + 1); 1932 ev_feed_signal_event (EV_A_ i + 1);
1925 } 1933 }
1927 1935
1928#if EV_ASYNC_ENABLE 1936#if EV_ASYNC_ENABLE
1929 if (async_pending) 1937 if (async_pending)
1930 { 1938 {
1931 async_pending = 0; 1939 async_pending = 0;
1940
1941 ECB_MEMORY_FENCE_RELEASE;
1932 1942
1933 for (i = asynccnt; i--; ) 1943 for (i = asynccnt; i--; )
1934 if (asyncs [i]->sent) 1944 if (asyncs [i]->sent)
1935 { 1945 {
1936 asyncs [i]->sent = 0; 1946 asyncs [i]->sent = 0;
2544#if EV_FEATURE_API 2554#if EV_FEATURE_API
2545void ecb_cold 2555void ecb_cold
2546ev_verify (EV_P) EV_THROW 2556ev_verify (EV_P) EV_THROW
2547{ 2557{
2548#if EV_VERIFY 2558#if EV_VERIFY
2549 int i; 2559 int i, j;
2550 WL w; 2560 WL w, w2;
2551 2561
2552 assert (activecnt >= -1); 2562 assert (activecnt >= -1);
2553 2563
2554 assert (fdchangemax >= fdchangecnt); 2564 assert (fdchangemax >= fdchangecnt);
2555 for (i = 0; i < fdchangecnt; ++i) 2565 for (i = 0; i < fdchangecnt; ++i)
2556 assert (("libev: negative fd in fdchanges", fdchanges [i] >= 0)); 2566 assert (("libev: negative fd in fdchanges", fdchanges [i] >= 0));
2557 2567
2558 assert (anfdmax >= 0); 2568 assert (anfdmax >= 0);
2559 for (i = 0; i < anfdmax; ++i) 2569 for (i = j = 0; i < anfdmax; ++i)
2560 for (w = anfds [i].head; w; w = w->next) 2570 for (w = w2 = anfds [i].head; w; w = w->next)
2561 { 2571 {
2562 verify_watcher (EV_A_ (W)w); 2572 verify_watcher (EV_A_ (W)w);
2573
2574 if (++j & 1)
2575 w2 = w2->next;
2576
2577 assert (("libev: io watcher list contains a loop", w != w2));
2563 assert (("libev: inactive fd watcher on anfd list", ev_active (w) == 1)); 2578 assert (("libev: inactive fd watcher on anfd list", ev_active (w) == 1));
2564 assert (("libev: fd mismatch between watcher and anfd", ((ev_io *)w)->fd == i)); 2579 assert (("libev: fd mismatch between watcher and anfd", ((ev_io *)w)->fd == i));
2565 } 2580 }
2566 2581
2567 assert (timermax >= timercnt); 2582 assert (timermax >= timercnt);
2677} 2692}
2678 2693
2679void noinline 2694void noinline
2680ev_invoke_pending (EV_P) 2695ev_invoke_pending (EV_P)
2681{ 2696{
2682 int pri; 2697 for (pendingpri = NUMPRI; pendingpri--; ) /* pendingpri is modified during the loop */
2683
2684 for (pri = NUMPRI; pri--; )
2685 while (pendingcnt [pri]) 2698 while (pendingcnt [pendingpri])
2686 { 2699 {
2687 ANPENDING *p = pendings [pri] + --pendingcnt [pri]; 2700 ANPENDING *p = pendings [pendingpri] + --pendingcnt [pendingpri];
2688 2701
2689 p->w->pending = 0; 2702 p->w->pending = 0;
2690 EV_CB_INVOKE (p->w, p->events); 2703 EV_CB_INVOKE (p->w, p->events);
2691 EV_FREQUENT_CHECK; 2704 EV_FREQUENT_CHECK;
2692 } 2705 }
3241 EV_FREQUENT_CHECK; 3254 EV_FREQUENT_CHECK;
3242 3255
3243 ev_start (EV_A_ (W)w, 1); 3256 ev_start (EV_A_ (W)w, 1);
3244 array_needsize (ANFD, anfds, anfdmax, fd + 1, array_init_zero); 3257 array_needsize (ANFD, anfds, anfdmax, fd + 1, array_init_zero);
3245 wlist_add (&anfds[fd].head, (WL)w); 3258 wlist_add (&anfds[fd].head, (WL)w);
3259
3260 /* common bug, apparently */
3261 assert (("libev: ev_io_start called with corrupted watcher", ((WL)w)->next != (WL)w));
3246 3262
3247 fd_change (EV_A_ fd, w->events & EV__IOFDSET | EV_ANFD_REIFY); 3263 fd_change (EV_A_ fd, w->events & EV__IOFDSET | EV_ANFD_REIFY);
3248 w->events &= ~EV__IOFDSET; 3264 w->events &= ~EV__IOFDSET;
3249 3265
3250 EV_FREQUENT_CHECK; 3266 EV_FREQUENT_CHECK;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines