From 3706fd17ebaf2722fb587c575ecbafefc9b52172 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 29 Nov 2017 19:27:13 +0100 Subject: [PATCH] settings: refactor update_auth_cb() and prepare connection once Note how nm_settings_connection_commit_changes() would call prepare() a second time. Don't do that. Also, move the prepare step earlier, and call _replace_settings_full() without preparing the new connection again. --- src/settings/nm-settings-connection.c | 34 +++++++++++++++------------ 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/src/settings/nm-settings-connection.c b/src/settings/nm-settings-connection.c index 54b3de1621..ea8bff4429 100644 --- a/src/settings/nm-settings-connection.c +++ b/src/settings/nm-settings-connection.c @@ -1716,7 +1716,9 @@ update_auth_cb (NMSettingsConnection *self, */ update_agent_secrets_cache (self, info->new_settings); } + } + if (info->new_settings) { if (nm_audit_manager_audit_enabled (nm_audit_manager_get ())) { gs_unref_hashtable GHashTable *diff = NULL; gboolean same; @@ -1730,17 +1732,6 @@ update_auth_cb (NMSettingsConnection *self, } } - if (!info->save_to_disk) { - if (info->new_settings) { - nm_settings_connection_replace_settings (self, - info->new_settings, - NM_SETTINGS_CONNECTION_PERSIST_MODE_IN_MEMORY, - "replace-unsaved", - &local); - } - goto out; - } - if (info->new_settings) { if (!nm_settings_connection_replace_settings_prepare (self, info->new_settings, @@ -1748,16 +1739,29 @@ update_auth_cb (NMSettingsConnection *self, goto out; } + if (!info->save_to_disk) { + if (info->new_settings) { + _replace_settings_full (self, + info->new_settings, + FALSE, + NM_SETTINGS_CONNECTION_PERSIST_MODE_IN_MEMORY, + "replace-unsaved", + &local); + } + goto out; + } + commit_reason = NM_SETTINGS_CONNECTION_COMMIT_REASON_USER_ACTION; if ( info->new_settings && !nm_streq0 (nm_connection_get_id (NM_CONNECTION (self)), nm_connection_get_id (info->new_settings))) commit_reason |= NM_SETTINGS_CONNECTION_COMMIT_REASON_ID_CHANGED; - nm_settings_connection_commit_changes (self, - info->new_settings, - commit_reason, - &local); + _commit_changes_full (self, + info->new_settings, + FALSE, + commit_reason, + &local); out: if (!local) {