--- libev/ev.c 2008/05/21 23:30:52 1.249 +++ libev/ev.c 2008/05/22 02:44:57 1.250 @@ -128,7 +128,7 @@ # define EV_USE_EVENTFD 0 # endif # endif - + #endif #include @@ -238,11 +238,15 @@ #endif #if 0 /* debugging */ -# define EV_VERIFY 1 +# define EV_VERIFY 3 # define EV_USE_4HEAP 1 # define EV_HEAP_CACHE_AT 1 #endif +#ifndef EV_VERIFY +# define EV_VERIFY !EV_MINIMAL +#endif + #ifndef EV_USE_4HEAP # define EV_USE_4HEAP !EV_MINIMAL #endif @@ -296,12 +300,7 @@ /**/ -/* EV_VERIFY: enable internal consistency checks - * undefined or zero: no verification done or available - * 1 or higher: ev_loop_verify function available - * 2 or higher: ev_loop_verify is called frequently - */ -#if EV_VERIFY >= 1 +#if EV_VERIFY >= 3 # define EV_FREQUENT_CHECK ev_loop_verify (EV_A) #else # define EV_FREQUENT_CHECK do { } while (0) @@ -1486,6 +1485,7 @@ } #if EV_MULTIPLICITY + struct ev_loop * ev_loop_new (unsigned int flags) { @@ -1521,10 +1521,12 @@ while (cnt--) assert (("active index mismatch", ev_active (ws [cnt]) == cnt + 1)); } +#endif -static void +void ev_loop_verify (EV_P) { +#if EV_VERIFY int i; checkheap (timers, timercnt); @@ -1539,15 +1541,15 @@ #if EV_FORK_ENABLE array_check ((W **)forks, forkcnt); #endif - array_check ((W **)prepares, preparecnt); - array_check ((W **)checks, checkcnt); #if EV_ASYNC_ENABLE array_check ((W **)asyncs, asynccnt); #endif -} + array_check ((W **)prepares, preparecnt); + array_check ((W **)checks, checkcnt); #endif +} -#endif +#endif /* multiplicity */ #if EV_MULTIPLICITY struct ev_loop * @@ -1622,8 +1624,6 @@ { int pri; - EV_FREQUENT_CHECK; - for (pri = NUMPRI; pri--; ) while (pendingcnt [pri]) { @@ -1635,10 +1635,9 @@ p->w->pending = 0; EV_CB_INVOKE (p->w, p->events); + EV_FREQUENT_CHECK; } } - - EV_FREQUENT_CHECK; } #if EV_IDLE_ENABLE @@ -1700,6 +1699,7 @@ periodics_reify (EV_P) { EV_FREQUENT_CHECK; + while (periodiccnt && ANHE_at (periodics [HEAP0]) < ev_rt_now) { ev_periodic *w = (ev_periodic *)ANHE_w (periodics [HEAP0]); @@ -1715,7 +1715,6 @@ ANHE_at_cache (periodics [HEAP0]); downheap (periodics, periodiccnt, HEAP0); - EV_FREQUENT_CHECK; } else if (w->interval) { @@ -1861,6 +1860,10 @@ do { +#if EV_VERIFY >= 2 + ev_loop_verify (EV_A); +#endif + #ifndef _WIN32 if (expect_false (curpid)) /* penalise the forking check even more */ if (expect_false (getpid () != curpid))