]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
timeout_add(0, ..) was looping in timeout handling code.
authorTimo Sirainen <tss@iki.fi>
Sat, 24 May 2008 22:30:11 +0000 (01:30 +0300)
committerTimo Sirainen <tss@iki.fi>
Sat, 24 May 2008 22:30:11 +0000 (01:30 +0300)
--HG--
branch : HEAD

src/lib/ioloop.c

index d89727eb24b1fbf390d855b569bd9e8ea0b75e90..406bebf1fa547f01f64df027c3e40992cc171081 100644 (file)
@@ -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);
 }