dovecot-1.1: timeout_add(0, ..) was looping in timeout handling ...

dovecot at dovecot.org dovecot at dovecot.org
Sun May 25 01:30:14 EEST 2008


details:   http://hg.dovecot.org/dovecot-1.1/rev/d432ef4835e3
changeset: 7537:d432ef4835e3
user:      Timo Sirainen <tss at iki.fi>
date:      Sun May 25 01:30:11 2008 +0300
description:
timeout_add(0, ..) was looping in timeout handling code.

diffstat:

1 file changed, 9 insertions(+), 2 deletions(-)
src/lib/ioloop.c |   11 +++++++++--

diffs (22 lines):

diff -r b6b3ea77e83e -r d432ef4835e3 src/lib/ioloop.c
--- a/src/lib/ioloop.c	Sun May 25 01:00:27 2008 +0300
+++ b/src/lib/ioloop.c	Sun May 25 01:30:11 2008 +0300
@@ -144,9 +144,16 @@ timeout_reset_timeval(struct timeout *ti
 		/* 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);
 }


More information about the dovecot-cvs mailing list