diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 28e073d0d3..02f631761a 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -10836,23 +10836,37 @@ _carrier_wait_check_act_request_must_queue (NMDevice *self, NMActRequest *req) } void -nm_device_steal_connection (NMDevice *self, NMSettingsConnection *connection) +nm_device_disconnect_active_connection (NMActiveConnection *active) { - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); + NMDevice *self; + NMDevicePrivate *priv; - _LOGI (LOGD_DEVICE, "disconnecting connection '%s' for new activation request", - nm_settings_connection_get_id (connection)); + g_return_if_fail (NM_IS_ACTIVE_CONNECTION (active)); - if ( priv->queued_act_request - && connection == nm_active_connection_get_settings_connection (NM_ACTIVE_CONNECTION (priv->queued_act_request))) + self = nm_active_connection_get_device (active); + + if (!self) { + /* hm, no device? Just fail the active connection. */ + nm_active_connection_set_state_fail (active, + NM_ACTIVE_CONNECTION_STATE_REASON_UNKNOWN, + NULL); + return; + } + + priv = NM_DEVICE_GET_PRIVATE (self); + + if (NM_ACTIVE_CONNECTION (priv->queued_act_request) == active) { _clear_queued_act_request (priv); - - if ( priv->act_request.obj - && connection == nm_active_connection_get_settings_connection (NM_ACTIVE_CONNECTION (priv->act_request.obj)) - && priv->state < NM_DEVICE_STATE_DEACTIVATING) { - nm_device_state_changed (self, - NM_DEVICE_STATE_DEACTIVATING, - NM_DEVICE_STATE_REASON_NEW_ACTIVATION); + return; + } + if (NM_ACTIVE_CONNECTION (priv->act_request.obj) == active) { + if (priv->state < NM_DEVICE_STATE_DEACTIVATING) { + nm_device_state_changed (self, + NM_DEVICE_STATE_DEACTIVATING, + NM_DEVICE_STATE_REASON_NEW_ACTIVATION); + } else { + /* it's going down already... */ + } } } diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h index 397123cd35..0d4d5cf8c4 100644 --- a/src/devices/nm-device.h +++ b/src/devices/nm-device.h @@ -717,7 +717,7 @@ void nm_device_queue_state (NMDevice *self, gboolean nm_device_get_firmware_missing (NMDevice *self); -void nm_device_steal_connection (NMDevice *device, NMSettingsConnection *connection); +void nm_device_disconnect_active_connection (NMActiveConnection *active); void nm_device_queue_activation (NMDevice *device, NMActRequest *req); diff --git a/src/nm-manager.c b/src/nm-manager.c index dc1f229b43..fc9a08f039 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -3954,7 +3954,7 @@ active_connection_parent_active (NMActiveConnection *active, static gboolean _internal_activate_device (NMManager *self, NMActiveConnection *active, GError **error) { - NMDevice *device, *existing, *master_device = NULL; + NMDevice *device, *master_device = NULL; NMActiveConnection *existing_ac; NMConnection *applied; NMSettingsConnection *connection; @@ -4121,11 +4121,8 @@ _internal_activate_device (NMManager *self, NMActiveConnection *active, GError * /* Disconnect the connection if connected or queued on another device */ existing_ac = active_connection_find (self, connection, NULL, NM_ACTIVE_CONNECTION_STATE_ACTIVATED, NULL); - if (existing_ac) { - existing = nm_active_connection_get_device (existing_ac); - if (existing) - nm_device_steal_connection (existing, connection); - } + if (existing_ac) + nm_device_disconnect_active_connection (existing_ac); /* If the device is there, we can ready it for the activation. */ if (nm_device_is_real (device)) {