From: Arne Schwabe Date: Mon, 10 Aug 2020 14:37:02 +0000 (+0200) Subject: Merge check_coarse_timers and check_coarse_timers_dowork X-Git-Tag: v2.5_beta1~10 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=42b39e987d55150b035c18c8b73c7ec08ef70d19;p=thirdparty%2Fopenvpn.git Merge check_coarse_timers and check_coarse_timers_dowork This simplifies the code a bit and makes the code flow clearer as it only adds three curly brackets in check_coarse_timers. Merging the resulting check_coarse_timers_dowork function into the caller and called function as with the other function does not make sense here since it does more than similar function. Signed-off-by: Arne Schwabe Acked-by: Gert Doering Message-Id: <20200810143707.5834-13-arne@rfc2549.org> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20671.html Signed-off-by: Gert Doering --- diff --git a/src/openvpn/forward.c b/src/openvpn/forward.c index 36e5c1759..7ed8d0d75 100644 --- a/src/openvpn/forward.c +++ b/src/openvpn/forward.c @@ -700,8 +700,14 @@ process_coarse_timers(struct context *c) } static void -check_coarse_timers_dowork(struct context *c) +check_coarse_timers(struct context *c) { + if (now < c->c2.coarse_timer_wakeup) + { + context_reschedule_sec(c, c->c2.coarse_timer_wakeup - now); + return; + } + const struct timeval save = c->c2.timeval; c->c2.timeval.tv_sec = BIG_TIMEOUT; c->c2.timeval.tv_usec = 0; @@ -717,20 +723,6 @@ check_coarse_timers_dowork(struct context *c) } } -static inline void -check_coarse_timers(struct context *c) -{ - const time_t local_now = now; - if (local_now >= c->c2.coarse_timer_wakeup) - { - check_coarse_timers_dowork(c); - } - else - { - context_reschedule_sec(c, c->c2.coarse_timer_wakeup - local_now); - } -} - static void check_timeout_random_component_dowork(struct context *c) {