From 6f3ae8a56306d2c6ab3dae45f53d5565660844f2 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 27 May 2020 17:05:02 +0200 Subject: [PATCH] core: in periodic_update_active_connection_timestamps() use same timestamp When performing a synchronous action together (like iterating over all settings and set the current timestamp), it's nicer to pretend that all this would happen instantaneously. That means, ensure we use the same timestamp throughout. On a minor point, there really is no need to call time() multiple times. --- src/nm-manager.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/nm-manager.c b/src/nm-manager.c index 8cee206bef..e8b3d7eff9 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -7344,12 +7344,19 @@ periodic_update_active_connection_timestamps (gpointer user_data) NMManager *manager = NM_MANAGER (user_data); NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager); NMActiveConnection *ac; + gboolean has_time = FALSE; + guint64 t; c_list_for_each_entry (ac, &priv->active_connections_lst_head, active_connections_lst) { - if (nm_active_connection_get_state (ac) == NM_ACTIVE_CONNECTION_STATE_ACTIVATED) { - nm_settings_connection_update_timestamp (nm_active_connection_get_settings_connection (ac), - (guint64) time (NULL)); + if (nm_active_connection_get_state (ac) != NM_ACTIVE_CONNECTION_STATE_ACTIVATED) + continue; + + if (!has_time) { + t = time (NULL); + has_time = TRUE; } + nm_settings_connection_update_timestamp (nm_active_connection_get_settings_connection (ac), + t); } return G_SOURCE_CONTINUE; }