From 7e49e32f18d8ba5d30764c597d61c1fbbb414326 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 7 Apr 2023 12:55:57 +0200 Subject: [PATCH] core: use GSource for tracking _device_recheck_auto_activate_all_cb idle action The numeric source IDs are discouraged. Use a GSource instead. (cherry picked from commit 1559c37b9f5f4a449413341275a331ef426f9d88) --- src/core/nm-policy.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/core/nm-policy.c b/src/core/nm-policy.c index af4a9196f9..d312da34af 100644 --- a/src/core/nm-policy.c +++ b/src/core/nm-policy.c @@ -62,6 +62,8 @@ typedef struct { NMSettings *settings; + GSource *device_recheck_auto_activate_all_idle_source; + NMHostnameManager *hostname_manager; NMActiveConnection *default_ac4, *activating_ac4; @@ -72,9 +74,6 @@ typedef struct { guint reset_retries_id; /* idle handler for resetting the retries count */ - guint - schedule_activate_all_id; /* idle handler for nm_policy_device_recheck_auto_activate_all_schedule(). */ - NMPolicyHostnameMode hostname_mode; char *orig_hostname; /* hostname at NM start time */ char *cur_hostname; /* hostname we want to assign */ @@ -2521,12 +2520,12 @@ _device_recheck_auto_activate_all_cb(gpointer user_data) const CList *tmp_lst; NMDevice *device; - priv->schedule_activate_all_id = 0; + nm_clear_g_source_inst(&priv->device_recheck_auto_activate_all_idle_source); nm_manager_for_each_device (priv->manager, device, tmp_lst) nm_policy_device_recheck_auto_activate_schedule(self, device); - return G_SOURCE_REMOVE; + return G_SOURCE_CONTINUE; } static void @@ -2536,8 +2535,10 @@ nm_policy_device_recheck_auto_activate_all_schedule(NMPolicy *self) /* always restart the idle handler. That way, we settle * all other events before restarting to activate them. */ - nm_clear_g_source(&priv->schedule_activate_all_id); - priv->schedule_activate_all_id = g_idle_add(_device_recheck_auto_activate_all_cb, self); + nm_clear_g_source_inst(&priv->device_recheck_auto_activate_all_idle_source); + + priv->device_recheck_auto_activate_all_idle_source = + nm_g_idle_add_source(_device_recheck_auto_activate_all_cb, self); } /*****************************************************************************/ @@ -2953,7 +2954,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(&priv->schedule_activate_all_id); + nm_clear_g_source_inst(&priv->device_recheck_auto_activate_all_idle_source); nm_clear_g_free(&priv->orig_hostname); nm_clear_g_free(&priv->cur_hostname);