diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2017-01-03 13:54:09 +0100 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2017-01-10 14:28:14 +0100 |
commit | fc56eff0aee72d1bb239de3e32620cd7679b5e86 (patch) | |
tree | dca2fb00d8c2706d31f5037473ba7954daa8074d | |
parent | 2a960d3936d78087d74ba556df8ac808639c96a0 (diff) |
settings: fix assertion when changing connection managed state
When a ifcfg-rh connection becomes unamanaged it is removed from the
connection list in NMSettings and marked as removed; it is however
kept alive in the plugin and can become managed again later. To avoid
failed assertions, the @removed flag of the NMSettingsConnection must
be cleared if the connection is not being disposed.
(cherry picked from commit a9384452ed61ca3f1c6e1db175f499307da9c388)
-rw-r--r-- | src/settings/nm-settings-connection.c | 12 | ||||
-rw-r--r-- | src/settings/nm-settings-connection.h | 2 | ||||
-rw-r--r-- | src/settings/plugins/ifcfg-rh/plugin.c | 4 | ||||
-rw-r--r-- | src/settings/plugins/ifnet/plugin.c | 4 | ||||
-rw-r--r-- | src/settings/plugins/keyfile/plugin.c | 2 |
5 files changed, 13 insertions, 11 deletions
diff --git a/src/settings/nm-settings-connection.c b/src/settings/nm-settings-connection.c index f22807d34..1aab5b853 100644 --- a/src/settings/nm-settings-connection.c +++ b/src/settings/nm-settings-connection.c @@ -752,7 +752,7 @@ do_delete (NMSettingsConnection *self, /* Remove connection from seen-bssids database file */ remove_entry_from_db (self, "seen-bssids"); - nm_settings_connection_signal_remove (self); + nm_settings_connection_signal_remove (self, FALSE); callback (self, NULL, user_data); @@ -2087,13 +2087,15 @@ impl_settings_connection_clear_secrets (NMSettingsConnection *self, /**************************************************************/ void -nm_settings_connection_signal_remove (NMSettingsConnection *self) +nm_settings_connection_signal_remove (NMSettingsConnection *self, gboolean allow_reuse) { NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self); - if (priv->removed) - g_return_if_reached (); - priv->removed = TRUE; + if (!allow_reuse) { + if (priv->removed) + g_return_if_reached (); + priv->removed = TRUE; + } g_signal_emit_by_name (self, NM_SETTINGS_CONNECTION_REMOVED); } diff --git a/src/settings/nm-settings-connection.h b/src/settings/nm-settings-connection.h index 761203ead..c515d66b7 100644 --- a/src/settings/nm-settings-connection.h +++ b/src/settings/nm-settings-connection.h @@ -173,7 +173,7 @@ void nm_settings_connection_recheck_visibility (NMSettingsConnection *self); gboolean nm_settings_connection_check_permission (NMSettingsConnection *self, const char *permission); -void nm_settings_connection_signal_remove (NMSettingsConnection *self); +void nm_settings_connection_signal_remove (NMSettingsConnection *self, gboolean allow_reuse); gboolean nm_settings_connection_get_unsaved (NMSettingsConnection *self); diff --git a/src/settings/plugins/ifcfg-rh/plugin.c b/src/settings/plugins/ifcfg-rh/plugin.c index c2956d22b..3b70bb489 100644 --- a/src/settings/plugins/ifcfg-rh/plugin.c +++ b/src/settings/plugins/ifcfg-rh/plugin.c @@ -145,7 +145,7 @@ remove_connection (SettingsPluginIfcfg *self, NMIfcfgConnection *connection) g_object_ref (connection); g_hash_table_remove (priv->connections, nm_connection_get_uuid (NM_CONNECTION (connection))); if (!unmanaged && !unrecognized) - nm_settings_connection_signal_remove (NM_SETTINGS_CONNECTION (connection)); + nm_settings_connection_signal_remove (NM_SETTINGS_CONNECTION (connection), FALSE); g_object_unref (connection); /* Emit changes _after_ removing the connection */ @@ -314,7 +314,7 @@ update_connection (SettingsPluginIfcfg *self, /* Unexport the connection by telling the settings service it's * been removed. */ - nm_settings_connection_signal_remove (NM_SETTINGS_CONNECTION (connection_by_uuid)); + nm_settings_connection_signal_remove (NM_SETTINGS_CONNECTION (connection_by_uuid), TRUE); /* Remove the path so that claim_connection() doesn't complain later when * interface gets managed and connection is re-added. */ nm_connection_set_path (NM_CONNECTION (connection_by_uuid), NULL); diff --git a/src/settings/plugins/ifnet/plugin.c b/src/settings/plugins/ifnet/plugin.c index a0676cf89..372e05600 100644 --- a/src/settings/plugins/ifnet/plugin.c +++ b/src/settings/plugins/ifnet/plugin.c @@ -240,7 +240,7 @@ reload_connections (NMSettingsPlugin *config) NM_SETTING_COMPARE_FLAG_IGNORE_NOT_SAVED_SECRETS)) { nm_log_info (LOGD_SETTINGS, "Auto refreshing %s", conn_name); - nm_settings_connection_signal_remove (NM_SETTINGS_CONNECTION (old)); + nm_settings_connection_signal_remove (NM_SETTINGS_CONNECTION (old), FALSE); track_new_connection (self, new); if (is_managed_plugin () && is_managed (conn_name)) g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_CONNECTION_ADDED, new); @@ -282,7 +282,7 @@ reload_connections (NMSettingsPlugin *config) */ if ( nm_ifnet_connection_get_conn_name (NM_IFNET_CONNECTION (candidate)) && !g_hash_table_lookup (new_connections, uuid)) { - nm_settings_connection_signal_remove (candidate); + nm_settings_connection_signal_remove (candidate, FALSE); g_hash_table_iter_remove (&iter); } } diff --git a/src/settings/plugins/keyfile/plugin.c b/src/settings/plugins/keyfile/plugin.c index c5598fc5b..539ca5b4f 100644 --- a/src/settings/plugins/keyfile/plugin.c +++ b/src/settings/plugins/keyfile/plugin.c @@ -82,7 +82,7 @@ remove_connection (SettingsPluginKeyfile *self, NMKeyfileConnection *connection) g_signal_handlers_disconnect_by_func (connection, connection_removed_cb, self); removed = g_hash_table_remove (SETTINGS_PLUGIN_KEYFILE_GET_PRIVATE (self)->connections, nm_connection_get_uuid (NM_CONNECTION (connection))); - nm_settings_connection_signal_remove (NM_SETTINGS_CONNECTION (connection)); + nm_settings_connection_signal_remove (NM_SETTINGS_CONNECTION (connection), FALSE); g_object_unref (connection); g_return_if_fail (removed); |