dovecot-2.2: lib: Fixed io_loop_move_timeout() to retain the nex...

dovecot at dovecot.org dovecot at dovecot.org
Sat Oct 4 14:33:31 UTC 2014


details:   http://hg.dovecot.org/dovecot-2.2/rev/312dd5c349f5
changeset: 17878:312dd5c349f5
user:      Stephan Bosch <stephan at rename-it.nl>
date:      Sat Oct 04 17:31:38 2014 +0300
description:
lib: Fixed io_loop_move_timeout() to retain the next_run time, so that the timeout is not implicitly reset.
This problem became with timeout_add_absolute(), since resetting an
absolute timeout causes it to fire immediately (msecs == 0).

diffstat:

 src/lib/ioloop.c |  18 ++++++++++++++++--
 1 files changed, 16 insertions(+), 2 deletions(-)

diffs (35 lines):

diff -r 9ce4d8d394cc -r 312dd5c349f5 src/lib/ioloop.c
--- a/src/lib/ioloop.c	Sat Oct 04 17:31:14 2014 +0300
+++ b/src/lib/ioloop.c	Sat Oct 04 17:31:38 2014 +0300
@@ -254,6 +254,21 @@
 	return timeout;
 }
 
+static struct timeout *
+timeout_copy(const struct timeout *old_to)
+{
+	struct timeout *new_to;
+
+	new_to = timeout_add_common
+		(old_to->source_linenum, old_to->callback, old_to->context);
+	new_to->one_shot = old_to->one_shot;
+	new_to->msecs = old_to->msecs;
+	new_to->next_run = old_to->next_run;
+	priorityq_add(new_to->ioloop->timeouts, &new_to->item);
+
+	return new_to;
+}
+
 static void timeout_free(struct timeout *timeout)
 {
 	if (timeout->ctx != NULL)
@@ -829,8 +844,7 @@
 	if (old_to->ioloop == current_ioloop)
 		return old_to;
 
-	new_to = timeout_add(old_to->msecs, old_to->source_linenum,
-			     old_to->callback, old_to->context);
+	new_to = timeout_copy(old_to);
 	timeout_remove(_timeout);
 	return new_to;
 }


More information about the dovecot-cvs mailing list