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.
This commit is contained in:
Thomas Haller
2020-05-27 17:05:02 +02:00
parent 968b444603
commit 6f3ae8a563

View File

@@ -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;
}