summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorroot <root>2012-06-02 11:15:29 +0000
committerroot <root>2012-06-02 11:15:29 +0000
commita7c9d84a337120b40a32ded730697681a3b8a0dc (patch)
tree34e47a8bcbcde79102d5e128ad8b7e44ce0aba29
parent50eeafb254ed0f93a3dda951c6ae26bf436be420 (diff)
avoid pendingpri < 0 during ev_run recursion
-rw-r--r--ev.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/ev.c b/ev.c
index 20bc3b0..52ee05c 100644
--- a/ev.c
+++ b/ev.c
@@ -2764,15 +2764,21 @@ ev_pending_count (EV_P) EV_THROW
void noinline
ev_invoke_pending (EV_P)
{
- for (pendingpri = NUMPRI; pendingpri--; ) /* pendingpri is modified during the loop */
- while (pendingcnt [pendingpri])
- {
- ANPENDING *p = pendings [pendingpri] + --pendingcnt [pendingpri];
+ pendingpri = NUMPRI;
- p->w->pending = 0;
- EV_CB_INVOKE (p->w, p->events);
- EV_FREQUENT_CHECK;
- }
+ while (pendingpri) /* pendingpri possibly gets modified in the inner loop */
+ {
+ --pendingpri;
+
+ while (pendingcnt [pendingpri])
+ {
+ ANPENDING *p = pendings [pendingpri] + --pendingcnt [pendingpri];
+
+ p->w->pending = 0;
+ EV_CB_INVOKE (p->w, p->events);
+ EV_FREQUENT_CHECK;
+ }
+ }
}
#if EV_IDLE_ENABLE
@@ -3180,10 +3186,6 @@ ev_run (EV_P_ int flags)
if (loop_done == EVBREAK_ONE)
loop_done = EVBREAK_CANCEL;
- /* pendingpri is normally -1 here, which is not a good */
- /* value when returning to an ev_invoke_pending */
- pendingpri = NUMPRI - 1;
-
#if EV_FEATURE_API
--loop_depth;
#endif