@@ -4184,16 +4184,14 @@
}
void
-management_check_bytecount_server(struct multi_context *multi)
+management_check_bytecount_server(struct multi_context *multi, struct timeval *timeval)
{
if (!(management->persist.callback.flags & MCF_SERVER))
{
return;
}
- struct timeval null;
- CLEAR(null);
- if (event_timeout_trigger(&management->connection.bytecount_update_interval, &null, ETT_DEFAULT))
+ if (event_timeout_trigger(&management->connection.bytecount_update_interval, timeval, ETT_DEFAULT))
{
/* fetch counters from dco */
if (dco_enabled(&multi->top.options))
@@ -493,7 +493,7 @@
void management_check_bytecount_client(struct context *c, struct management *man, struct timeval *timeval);
-void management_check_bytecount_server(struct multi_context *multi);
+void management_check_bytecount_server(struct multi_context *multi, struct timeval *timeval);
void man_persist_client_stats(struct management *man, struct context *c);
@@ -3809,13 +3809,6 @@
{
check_stale_routes(m);
}
-
-#ifdef ENABLE_MANAGEMENT
- if (management)
- {
- management_check_bytecount_server(m);
- }
-#endif /* ENABLE_MANAGEMENT */
}
static void
@@ -4166,6 +4159,29 @@
ASSERT(mi->context.c2.tls_multi->peer_id < m->max_clients);
}
+/**
+ * @brief Determines the earliest wakeup interval based on periodic operations.
+ *
+ * Updates the \c timeval to reflect the next scheduled wakeup time.
+ * Also sets \c multi->earliest_wakeup to the instance with the earliest wakeup.
+ *
+ * @param multi Pointer to the multi context
+ * @param timeval Pointer to the timeval structure to be updated with the
+ * next wakeup time
+ */
+static void
+multi_get_timeout(struct multi_context *multi, struct timeval *timeval)
+{
+ multi_get_timeout_instance(multi, timeval);
+
+#ifdef ENABLE_MANAGEMENT
+ if (management)
+ {
+ management_check_bytecount_server(multi, timeval);
+ }
+#endif /* ENABLE_MANAGEMENT */
+}
+
/**************************************************************************/
/**
* Main event loop for OpenVPN in point-to-multipoint server mode.
@@ -582,15 +582,16 @@
}
/*
- * Compute earliest timeout expiry from the set of
- * all instances. Output:
+ * Updates \c dest with the earliest timeout as a delta relative to the current
+ * time and sets \c m->earliest_wakeup to the \c multi_instance with the
+ * soonest scheduled wakeup.
*
- * m->earliest_wakeup : instance needing the earliest service.
- * dest : earliest timeout as a delta in relation
- * to current time.
+ * @param m Pointer to the multi context
+ * @param dest Pointer to a timeval struct that will hold the earliest timeout
+ * delta.
*/
static inline void
-multi_get_timeout(struct multi_context *m, struct timeval *dest)
+multi_get_timeout_instance(struct multi_context *m, struct timeval *dest)
{
struct timeval tv, current;