]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: Fix updating timeouts after time moves backwards
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Sat, 17 Aug 2019 10:44:53 +0000 (13:44 +0300)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Tue, 10 Sep 2019 07:02:20 +0000 (10:02 +0300)
Broken by b258137d0e0618ae792e3606071a1715d26f107b

Fixes:
Panic: file ioloop.c: line 479 (timeout_get_wait_time): assertion failed: (ret > 0 && tv_r->tv_sec >= 0 && tv_r->tv_usec >= 0)

src/lib/ioloop.c

index 20016eac1a721b3d17913ebd640d61dd8b93be51..64fdb54a2965346875b9ce301a308bb52976f8a7 100644 (file)
@@ -592,7 +592,10 @@ static void io_loop_timeouts_update(struct ioloop *ioloop, long long diff_usecs)
        for (i = 0; i < count; i++) {
                struct timeout *to = (struct timeout *)items[i];
 
-               timeval_add_usecs(&to->next_run, diff_usecs);
+               if (diff_usecs > 0)
+                       timeval_add_usecs(&to->next_run, diff_usecs);
+               else
+                       timeval_sub_usecs(&to->next_run, -diff_usecs);
        }
 }