diff options
author | Thomas Haller <thaller@redhat.com> | 2023-04-07 13:08:14 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2023-04-27 08:35:28 +0200 |
commit | aa2569a9cdff9e9a0afbe99a394b5f351a7b1506 (patch) | |
tree | 8cf652146aab70d82dacdeb5df8584de71ed7f91 /src/core/nm-policy.c | |
parent | 1559c37b9f5f4a449413341275a331ef426f9d88 (diff) | |
download | NetworkManager-aa2569a9cdff9e9a0afbe99a394b5f351a7b1506.tar.gz |
core: use GSource for tracking reset_connections_retries idle action
The numeric source IDs are discouraged. Use a GSource instead.
Diffstat (limited to 'src/core/nm-policy.c')
-rw-r--r-- | src/core/nm-policy.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/src/core/nm-policy.c b/src/core/nm-policy.c index ef874c35ad..bbf498f5d1 100644 --- a/src/core/nm-policy.c +++ b/src/core/nm-policy.c @@ -64,6 +64,8 @@ typedef struct { GSource *device_recheck_auto_activate_all_idle_source; + GSource *reset_connections_retries_idle_source; + NMHostnameManager *hostname_manager; NMActiveConnection *default_ac4, *activating_ac4; @@ -72,8 +74,6 @@ typedef struct { NMDnsManager *dns_manager; gulong config_changed_id; - guint reset_retries_id; /* idle handler for resetting the retries count */ - NMPolicyHostnameMode hostname_mode; char *orig_hostname; /* hostname at NM start time */ char *cur_hostname; /* hostname we want to assign */ @@ -1720,7 +1720,7 @@ reset_connections_retries(gpointer user_data) gint32 con_stamp, min_stamp, now; gboolean changed = FALSE; - priv->reset_retries_id = 0; + nm_clear_g_source_inst(&priv->reset_connections_retries_idle_source); min_stamp = 0; now = nm_utils_get_monotonic_timestamp_sec(); @@ -1741,15 +1741,16 @@ reset_connections_retries(gpointer user_data) } /* Schedule the handler again if there are some stamps left */ - if (min_stamp != 0) - priv->reset_retries_id = - g_timeout_add_seconds(min_stamp - now, reset_connections_retries, self); + if (min_stamp != 0) { + priv->reset_connections_retries_idle_source = + nm_g_timeout_add_seconds_source(min_stamp - now, reset_connections_retries, self); + } /* If anything changed, try to activate the newly re-enabled connections */ if (changed) nm_policy_device_recheck_auto_activate_all_schedule(self); - return FALSE; + return G_SOURCE_CONTINUE; } static void @@ -1766,16 +1767,16 @@ _connection_autoconnect_retries_set(NMPolicy *self, if (tries == 0) { /* Schedule a handler to reset retries count */ - if (!priv->reset_retries_id) { + if (!priv->reset_connections_retries_idle_source) { gint32 retry_time = nm_manager_devcon_autoconnect_retries_blocked_until(priv->manager, device, connection); g_warn_if_fail(retry_time != 0); - priv->reset_retries_id = - g_timeout_add_seconds(MAX(0, retry_time - nm_utils_get_monotonic_timestamp_sec()), - reset_connections_retries, - self); + priv->reset_connections_retries_idle_source = nm_g_timeout_add_seconds_source( + MAX(0, retry_time - nm_utils_get_monotonic_timestamp_sec()), + reset_connections_retries, + self); } } } @@ -2938,7 +2939,7 @@ dispose(GObject *object) */ nm_assert(c_list_is_empty(nm_manager_get_active_connections(priv->manager))); - nm_clear_g_source(&priv->reset_retries_id); + nm_clear_g_source_inst(&priv->reset_connections_retries_idle_source); nm_clear_g_source_inst(&priv->device_recheck_auto_activate_all_idle_source); nm_clear_g_free(&priv->orig_hostname); |