From c5a97ad265a701f70edbf87329778d7fa0cfddaa Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 5 Feb 2018 16:41:10 +0100 Subject: [PATCH] manager: use nm_active_connection_set_state_fail() instead of _internal_activation_failed() There is a small change in behavior: Previously, the DEACTIVATING/DEACTIVATED states were set if and only if the previous state was less or equal then ACTIVATED. For example, if the state was already DEACTIVATING, it would have done nothing. Now, nm_active_connection_set_state_fail() transitions the states depending on the previous state. E.g. it would only set DEACTIVATING state, if the previous state was ACTIVATING/ACTIVATED. On the other hand, it would always progress the state to DEACTIVATED. The new behavior makes more sense to me, although I doubt that there is a visible difference. --- src/nm-manager.c | 33 ++++++++++----------------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/src/nm-manager.c b/src/nm-manager.c index a498758d49..19d67e550c 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -3941,25 +3941,6 @@ _new_active_connection (NMManager *self, device); } -static void -_internal_activation_failed (NMManager *self, - NMActiveConnection *active, - const char *error_desc) -{ - _LOGD (LOGD_CORE, "Failed to activate '%s': %s", - nm_active_connection_get_settings_connection_id (active), - error_desc); - - if (nm_active_connection_get_state (active) <= NM_ACTIVE_CONNECTION_STATE_ACTIVATED) { - nm_active_connection_set_state (active, - NM_ACTIVE_CONNECTION_STATE_DEACTIVATING, - NM_ACTIVE_CONNECTION_STATE_REASON_UNKNOWN); - nm_active_connection_set_state (active, - NM_ACTIVE_CONNECTION_STATE_DEACTIVATED, - NM_ACTIVE_CONNECTION_STATE_REASON_UNKNOWN); - } -} - static void _internal_activation_auth_done (NMActiveConnection *active, gboolean success, @@ -4005,7 +3986,9 @@ _internal_activation_auth_done (NMActiveConnection *active, } nm_assert (error_desc || error); - _internal_activation_failed (self, active, error_desc ? error_desc : error->message); + nm_active_connection_set_state_fail (active, + NM_ACTIVE_CONNECTION_STATE_REASON_UNKNOWN, + error_desc ?: error->message); } /** @@ -4249,7 +4232,9 @@ _activation_auth_done (NMActiveConnection *active, nm_audit_log_connection_op (NM_AUDIT_OP_CONN_ACTIVATE, connection, FALSE, NULL, subject, error->message); - _internal_activation_failed (self, active, error->message); + nm_active_connection_set_state_fail (active, + NM_ACTIVE_CONNECTION_STATE_REASON_UNKNOWN, + error->message); g_dbus_method_invocation_take_error (context, error); } @@ -4398,8 +4383,10 @@ activation_add_done (NMSettings *settings, error = local; } - g_assert (error); - _internal_activation_failed (self, active, error->message); + nm_assert (error); + nm_active_connection_set_state_fail (active, + NM_ACTIVE_CONNECTION_STATE_REASON_UNKNOWN, + error->message); if (new_connection) nm_settings_connection_delete (new_connection, NULL); g_dbus_method_invocation_return_gerror (context, error);