From: Timo Sirainen Date: Sat, 24 May 2008 22:30:11 +0000 (+0300) Subject: timeout_add(0, ..) was looping in timeout handling code. X-Git-Tag: 1.1.rc6~38 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1ca87894d589f407dd676b6e814fb317367b5c36;p=thirdparty%2Fdovecot%2Fcore.git timeout_add(0, ..) was looping in timeout handling code. --HG-- branch : HEAD --- 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); }