From f9e0c44925d28fd719cd96b7b64927d5af4857a0 Mon Sep 17 00:00:00 2001 From: Niels Provos Date: Thu, 10 Apr 2003 19:14:03 +0000 Subject: [PATCH] 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 --- event.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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); -- 2.50.1