mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-07 18:58:05 +02:00
policy: refactor auto_activate_device() to return early
This commit is contained in:
parent
bfe66fb8f4
commit
a7ef46eaaa
1 changed files with 38 additions and 38 deletions
|
|
@ -1213,6 +1213,9 @@ auto_activate_device (NMPolicy *self,
|
||||||
gs_free char *specific_object = NULL;
|
gs_free char *specific_object = NULL;
|
||||||
gs_free NMSettingsConnection **connections = NULL;
|
gs_free NMSettingsConnection **connections = NULL;
|
||||||
guint i, len;
|
guint i, len;
|
||||||
|
GError *error = NULL;
|
||||||
|
NMAuthSubject *subject;
|
||||||
|
NMActiveConnection *ac;
|
||||||
|
|
||||||
nm_assert (NM_IS_POLICY (self));
|
nm_assert (NM_IS_POLICY (self));
|
||||||
nm_assert (NM_IS_DEVICE (device));
|
nm_assert (NM_IS_DEVICE (device));
|
||||||
|
|
@ -1260,46 +1263,43 @@ auto_activate_device (NMPolicy *self,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (best_connection) {
|
if (!best_connection)
|
||||||
GError *error = NULL;
|
return;
|
||||||
NMAuthSubject *subject;
|
|
||||||
NMActiveConnection *ac;
|
|
||||||
|
|
||||||
_LOGI (LOGD_DEVICE, "auto-activating connection '%s'",
|
_LOGI (LOGD_DEVICE, "auto-activating connection '%s'",
|
||||||
nm_settings_connection_get_id (best_connection));
|
nm_settings_connection_get_id (best_connection));
|
||||||
subject = nm_auth_subject_new_internal ();
|
subject = nm_auth_subject_new_internal ();
|
||||||
ac = nm_manager_activate_connection (priv->manager,
|
ac = nm_manager_activate_connection (priv->manager,
|
||||||
best_connection,
|
best_connection,
|
||||||
NULL,
|
NULL,
|
||||||
specific_object,
|
specific_object,
|
||||||
device,
|
device,
|
||||||
subject,
|
subject,
|
||||||
NM_ACTIVATION_TYPE_MANAGED,
|
NM_ACTIVATION_TYPE_MANAGED,
|
||||||
&error);
|
&error);
|
||||||
if (!ac) {
|
if (!ac) {
|
||||||
_LOGI (LOGD_DEVICE, "connection '%s' auto-activation failed: (%d) %s",
|
_LOGI (LOGD_DEVICE, "connection '%s' auto-activation failed: (%d) %s",
|
||||||
nm_settings_connection_get_id (best_connection),
|
nm_settings_connection_get_id (best_connection),
|
||||||
error->code,
|
error->code,
|
||||||
error->message);
|
error->message);
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
nm_settings_connection_autoconnect_blocked_reason_set (best_connection,
|
nm_settings_connection_autoconnect_blocked_reason_set (best_connection,
|
||||||
NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_FAILED);
|
NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_FAILED);
|
||||||
schedule_activate_check (self, device);
|
schedule_activate_check (self, device);
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
/* Subscribe to AC state-changed signal to detect when the
|
|
||||||
* activation fails in early stages without changing device
|
|
||||||
* state.
|
|
||||||
*/
|
|
||||||
if (nm_g_hash_table_add (priv->pending_active_connections, ac)) {
|
|
||||||
g_signal_connect (ac, NM_ACTIVE_CONNECTION_STATE_CHANGED,
|
|
||||||
G_CALLBACK (pending_ac_state_changed), g_object_ref (self));
|
|
||||||
g_object_weak_ref (G_OBJECT (ac), (GWeakNotify) pending_ac_gone, self);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_object_unref (subject);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Subscribe to AC state-changed signal to detect when the
|
||||||
|
* activation fails in early stages without changing device
|
||||||
|
* state.
|
||||||
|
*/
|
||||||
|
if (nm_g_hash_table_add (priv->pending_active_connections, ac)) {
|
||||||
|
g_signal_connect (ac, NM_ACTIVE_CONNECTION_STATE_CHANGED,
|
||||||
|
G_CALLBACK (pending_ac_state_changed), g_object_ref (self));
|
||||||
|
g_object_weak_ref (G_OBJECT (ac), (GWeakNotify) pending_ac_gone, self);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_object_unref (subject);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue