From: Guus Sliepen Date: Mon, 26 Feb 2018 21:19:43 +0000 (+0100) Subject: Unconditionally remove timeouts from the queue before calling the callback. X-Git-Tag: release-1.1pre16~18 X-Git-Url: https://tinc-vpn.org/git/browse?a=commitdiff_plain;h=e8a60109fc91a42420ec626b63956771675f89b0;p=tinc Unconditionally remove timeouts from the queue before calling the callback. We are going to unlink the timeout from the splay tree anyway, so do it unconditionally before the callback, instead of waiting until after the callback to check whether or not to remove it based on its expiration time. --- diff --git a/src/event.c b/src/event.c index 331872a5..33d205a9 100644 --- a/src/event.c +++ b/src/event.c @@ -300,11 +300,9 @@ static struct timeval *get_time_remaining(struct timeval *diff) { timersub(&timeout->tv, &now, diff); if(diff->tv_sec < 0) { - timeout->cb(timeout->data); - - if(timercmp(&timeout->tv, &now, <)) { - timeout_del(timeout); - } + timeout_cb_t cb = timeout->cb; + timeout_del(timeout); + cb(timeout->data); } else { tv = diff; break;