mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-08 19:28:04 +02:00
tui: fix deletion of slaves with master (rh #1131574)
We wait for each deletion to complete, so the connections were getting removed from the connections array as we edited it (unlike with the old transfer-container GSList-based code). Fix this by copying the slaves out into their own list first.
This commit is contained in:
parent
820e41645f
commit
5bfb4c8c23
1 changed files with 12 additions and 5 deletions
|
|
@ -515,7 +515,8 @@ remove_one_connection (NMRemoteConnection *connection)
|
|||
void
|
||||
nmt_remove_connection (NMRemoteConnection *connection)
|
||||
{
|
||||
const GPtrArray *conns;
|
||||
const GPtrArray *all_conns;
|
||||
GSList *slaves, *iter;
|
||||
int i;
|
||||
NMRemoteConnection *slave;
|
||||
NMSettingConnection *s_con;
|
||||
|
|
@ -535,16 +536,22 @@ nmt_remove_connection (NMRemoteConnection *connection)
|
|||
uuid = nm_connection_get_uuid (NM_CONNECTION (connection));
|
||||
iface = nm_connection_get_interface_name (NM_CONNECTION (connection));
|
||||
|
||||
conns = nm_client_get_connections (nm_client);
|
||||
for (i = 0; i < conns->len; i++) {
|
||||
slave = conns->pdata[i];
|
||||
all_conns = nm_client_get_connections (nm_client);
|
||||
slaves = NULL;
|
||||
for (i = 0; i < all_conns->len; i++) {
|
||||
slave = all_conns->pdata[i];
|
||||
s_con = nm_connection_get_setting_connection (NM_CONNECTION (slave));
|
||||
master = nm_setting_connection_get_master (s_con);
|
||||
if (master) {
|
||||
if (!g_strcmp0 (master, uuid) || !g_strcmp0 (master, iface))
|
||||
remove_one_connection (slave);
|
||||
slaves = g_slist_prepend (slaves, g_object_ref (slave));
|
||||
}
|
||||
}
|
||||
|
||||
for (iter = slaves; iter; iter = iter->next)
|
||||
remove_one_connection (iter->data);
|
||||
g_slist_free_full (slaves, g_object_unref);
|
||||
|
||||
g_object_unref (connection);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue