From: Stephan Bosch Date: Sat, 4 Oct 2014 14:31:38 +0000 (+0300) Subject: lib: Fixed io_loop_move_timeout() to retain the next_run time, so that the timeout... X-Git-Tag: 2.2.14~72 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b3ba8f62212c3e0cb8c27fb5e87e0419a47397c8;p=thirdparty%2Fdovecot%2Fcore.git 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). --- diff --git a/src/lib/ioloop.c b/src/lib/ioloop.c index a58ce0182e..d5a014f4dd 100644 --- a/src/lib/ioloop.c +++ b/src/lib/ioloop.c @@ -254,6 +254,21 @@ timeout_add_absolute(const struct timeval *time, 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 @@ struct timeout *io_loop_move_timeout(struct timeout **_timeout) 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; }