From 1ca87894d589f407dd676b6e814fb317367b5c36 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Sun, 25 May 2008 01:30:11 +0300 Subject: [PATCH] timeout_add(0, ..) was looping in timeout handling code. --HG-- branch : HEAD --- src/lib/ioloop.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/lib/ioloop.c b/src/lib/ioloop.c index d89727eb24..406bebf1fa 100644 --- a/src/lib/ioloop.c +++ b/src/lib/ioloop.c @@ -144,9 +144,16 @@ timeout_reset_timeval(struct timeout *timeout, struct timeval *tv_now) /* if we came here from io_loop_handle_timeouts(), next_run must be larger than tv_now or we could go to infinite loop */ - if (++timeout->next_run.tv_usec == 0) + timeout->next_run.tv_usec += 1000; + if (timeout->next_run.tv_usec >= 1000000) { timeout->next_run.tv_sec++; + timeout->next_run.tv_usec -= 1000000; + } } + i_assert(tv_now == NULL || + timeout->next_run.tv_sec > tv_now->tv_sec || + (timeout->next_run.tv_sec == tv_now->tv_sec && + timeout->next_run.tv_usec > tv_now->tv_usec)); priorityq_remove(current_ioloop->timeouts, &timeout->item); priorityq_add(current_ioloop->timeouts, &timeout->item); } -- 2.47.3