From: Niels Provos Date: Thu, 10 Apr 2003 19:14:03 +0000 (+0000) Subject: if a timeout on the active list is rescheduled before it can execute it X-Git-Tag: release-1.1b~104 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f9e0c44925d28fd719cd96b7b64927d5af4857a0;p=libevent if a timeout on the active list is rescheduled before it can execute it gets removed from the active list; bug report from Jon Poland AT arbor.net svn:r65 --- diff --git a/event.c b/event.c index e31e49b6..a25d6e69 100644 --- a/event.c +++ b/event.c @@ -310,6 +310,22 @@ event_add(struct event *ev, struct timeval *tv) if (ev->ev_flags & EVLIST_TIMEOUT) event_queue_remove(ev, EVLIST_TIMEOUT); + /* Check if it is active due to a timeout. Rescheduling + * this timeout before the callback can be executed + * removes it from the active list. */ + if ((ev->ev_flags & EVLIST_ACTIVE) && + (ev->ev_res & EV_TIMEOUT)) { + /* See if we are just active executing this + * event in a loop + */ + if (ev->ev_ncalls && ev->ev_pncalls) { + /* Abort loop */ + *ev->ev_pncalls = 0; + } + + event_queue_remove(ev, EVLIST_ACTIVE); + } + gettimeofday(&now, NULL); timeradd(&now, tv, &ev->ev_timeout);