summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2017-11-29 19:27:13 +0100
committerThomas Haller <thaller@redhat.com>2017-12-05 21:24:22 +0100
commitea6e4f552b5dcf718f7a5a329bdb63f2ca9c260a (patch)
tree9b92dfd931efa7639bdef19328684bab62fc2fbf
parentf3b97cac0e0f18622f90a4a7b8af4d9e5b7f5d7d (diff)
downloadNetworkManager-ea6e4f552b5dcf718f7a5a329bdb63f2ca9c260a.tar.gz
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. (cherry picked from commit 3706fd17ebaf2722fb587c575ecbafefc9b52172)
-rw-r--r--src/settings/nm-settings-connection.c34
1 files 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) {