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 3706fd17eb)
This commit is contained in:
Thomas Haller 2017-11-29 19:27:13 +01:00
parent 0d0b778c29
commit 359e52651b

View file

@ -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) {