]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Merge check_coarse_timers and check_coarse_timers_dowork
authorArne Schwabe <arne@rfc2549.org>
Mon, 10 Aug 2020 14:37:02 +0000 (16:37 +0200)
committerGert Doering <gert@greenie.muc.de>
Mon, 10 Aug 2020 18:34:19 +0000 (20:34 +0200)
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 <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
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 <gert@greenie.muc.de>
src/openvpn/forward.c

index 36e5c17599d9fb6b69e8bd2d43e33e10a2f1d379..7ed8d0d7518a8c332eb4b0c9843487e39a27ca75 100644 (file)
@@ -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)
 {