core: assert that devices are not registered when disposing NMPolicy

NMDevice holds a reference to NMManager, which holds a reference to NMPolicy.
It is not possible that we try to dispose NMPolicy while there are still devices
registered. That would be a bug, that we need to find and solve
differently. Add an assertion instead of trying to handle it.
This commit is contained in:
Thomas Haller
2023-04-07 13:34:34 +02:00
parent 0dd4724446
commit aede228974

View File

@@ -2870,8 +2870,9 @@ dispose(GObject *object)
{
NMPolicy *self = NM_POLICY(object);
NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE(self);
GHashTableIter h_iter;
NMDevice *device;
nm_assert(!c_list_is_empty(&priv->policy_auto_activate_lst_head));
nm_assert(g_hash_table_size(priv->devices) == 0);
nm_clear_g_object(&priv->default_ac4);
nm_clear_g_object(&priv->default_ac6);
@@ -2879,11 +2880,6 @@ dispose(GObject *object)
nm_clear_g_object(&priv->activating_ac6);
nm_clear_pointer(&priv->pending_active_connections, g_hash_table_unref);
while ((device = c_list_first_entry(&priv->policy_auto_activate_lst_head,
NMDevice,
policy_auto_activate_lst)))
_auto_activate_device_clear(self, device, FALSE);
g_slist_free_full(priv->pending_secondaries, (GDestroyNotify) pending_secondary_data_free);
priv->pending_secondaries = NULL;
@@ -2902,12 +2898,6 @@ dispose(GObject *object)
g_clear_object(&priv->dns_manager);
}
g_hash_table_iter_init(&h_iter, priv->devices);
while (g_hash_table_iter_next(&h_iter, (gpointer *) &device, NULL)) {
g_hash_table_iter_remove(&h_iter);
devices_list_unregister(self, device);
}
/* The manager should have disposed of ActiveConnections already, which
* will have called active_connection_removed() and thus we don't need
* to clean anything up. Assert that this is TRUE.