Browse code

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 <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>

Arne Schwabe authored on 2020/08/10 23:37:02
Showing 1 changed files
... ...
@@ -700,8 +700,14 @@ process_coarse_timers(struct context *c)
700 700
 }
701 701
 
702 702
 static void
703
-check_coarse_timers_dowork(struct context *c)
703
+check_coarse_timers(struct context *c)
704 704
 {
705
+    if (now < c->c2.coarse_timer_wakeup)
706
+    {
707
+        context_reschedule_sec(c, c->c2.coarse_timer_wakeup - now);
708
+        return;
709
+    }
710
+
705 711
     const struct timeval save = c->c2.timeval;
706 712
     c->c2.timeval.tv_sec = BIG_TIMEOUT;
707 713
     c->c2.timeval.tv_usec = 0;
... ...
@@ -717,20 +723,6 @@ check_coarse_timers_dowork(struct context *c)
717 717
     }
718 718
 }
719 719
 
720
-static inline void
721
-check_coarse_timers(struct context *c)
722
-{
723
-    const time_t local_now = now;
724
-    if (local_now >= c->c2.coarse_timer_wakeup)
725
-    {
726
-        check_coarse_timers_dowork(c);
727
-    }
728
-    else
729
-    {
730
-        context_reschedule_sec(c, c->c2.coarse_timer_wakeup - local_now);
731
-    }
732
-}
733
-
734 720
 static void
735 721
 check_timeout_random_component_dowork(struct context *c)
736 722
 {