dovecot-2.2: lib: ioloop: Fixed absolute timeout removal.

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


details:   http://hg.dovecot.org/dovecot-2.2/rev/9ce4d8d394cc
changeset: 17877:9ce4d8d394cc
user:      Stephan Bosch <stephan at rename-it.nl>
date:      Sat Oct 04 17:31:14 2014 +0300
description:
lib: ioloop: Fixed absolute timeout removal.
Absolute timeouts fire only once, so the timeout should be removed from the
priority queue once it fires.

diffstat:

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

diffs (33 lines):

diff -r ecb0ba0ce02f -r 9ce4d8d394cc src/lib/ioloop.c
--- a/src/lib/ioloop.c	Sat Oct 04 17:30:54 2014 +0300
+++ b/src/lib/ioloop.c	Sat Oct 04 17:31:14 2014 +0300
@@ -266,7 +266,8 @@
 	struct timeout *timeout = *_timeout;
 
 	*_timeout = NULL;
-	priorityq_remove(timeout->ioloop->timeouts, &timeout->item);
+	if (timeout->item.idx != UINT_MAX)
+		priorityq_remove(timeout->ioloop->timeouts, &timeout->item);
 	timeout_free(timeout);
 }
 
@@ -295,6 +296,7 @@
 
 void timeout_reset(struct timeout *timeout)
 {
+	i_assert(!timeout->one_shot);
 	timeout_reset_timeval(timeout, NULL);
 }
 
@@ -434,7 +436,10 @@
 		if (timeout_get_wait_time(timeout, &tv, &tv_call) > 0)
 			break;
 
-		if (!timeout->one_shot) {
+		if (timeout->one_shot) {
+			/* remove timeout from queue */
+			priorityq_remove(timeout->ioloop->timeouts, &timeout->item);
+		} else {
 			/* update timeout's next_run and reposition it in the queue */
 			timeout_reset_timeval(timeout, &tv_call);
 		}


More information about the dovecot-cvs mailing list