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.

(cherry picked from commit c5a97ad265)
This commit is contained in:
Thomas Haller 2018-02-05 16:41:10 +01:00
parent 4b35d0c109
commit 5769d357c7

View file

@ -3943,25 +3943,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,
@ -4007,7 +3988,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);
}
/**
@ -4251,7 +4234,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);
}
@ -4400,8 +4385,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);