diff options
author | Thomas Haller <thaller@redhat.com> | 2023-04-07 13:23:59 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2023-04-27 08:40:12 +0200 |
commit | 0dd4724446fdef043fddc9f1e20569cacb78474d (patch) | |
tree | e6674a64e10d6f95c6d01510c224eee4d4c82856 | |
parent | a22e5080a0a67a76fd9fa17f69491267fbe89f72 (diff) | |
download | NetworkManager-0dd4724446fdef043fddc9f1e20569cacb78474d.tar.gz |
core: don't take reference on NMDevice to track auto-activate
Add an assertion to nm_policy_device_recheck_auto_activate_schedule(),
that the device is currently registered in NMPolicy. Calling it outside
would be odd, and likely a bug.
But if we only register the auto-activate while being registered, we
don't need to take an additional reference. We know that the object must
be be alive (also, we have assertions that in fact it is still alive).
-rw-r--r-- | src/core/nm-policy.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/core/nm-policy.c b/src/core/nm-policy.c index 26556c347e..ef0d8456ba 100644 --- a/src/core/nm-policy.c +++ b/src/core/nm-policy.c @@ -1460,7 +1460,6 @@ _auto_activate_device_clear(NMPolicy *self, NMDevice *device, gboolean do_activa _auto_activate_device(self, device); nm_device_remove_pending_action(device, NM_PENDING_ACTION_AUTOACTIVATE, TRUE); - g_object_unref(device); } static gboolean @@ -1663,6 +1662,14 @@ nm_policy_device_recheck_auto_activate_schedule(NMPolicy *self, NMDevice *device g_return_if_fail(NM_IS_POLICY(self)); g_return_if_fail(NM_IS_DEVICE(device)); + nm_assert(g_signal_handler_find(device, + G_SIGNAL_MATCH_DATA, + 0, + 0, + NULL, + NULL, + NM_POLICY_GET_PRIVATE(self)) + != 0); if (!c_list_is_empty(&device->policy_auto_activate_lst)) { /* already queued. Return. */ @@ -1691,7 +1698,6 @@ nm_policy_device_recheck_auto_activate_schedule(NMPolicy *self, NMDevice *device c_list_link_tail(&priv->policy_auto_activate_lst_head, &device->policy_auto_activate_lst); device->policy_auto_activate_idle_source = nm_g_idle_add_source(_auto_activate_idle_cb, device); - g_object_ref(device); } static gboolean |