--- libev/ev.c 2012/06/01 22:01:13 1.444 +++ libev/ev.c 2012/06/02 11:15:29 1.445 @@ -2764,15 +2764,21 @@ 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 @@ 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