From e1b0451d688231eec4c00a1fb92c5be2fbaae3a9 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 20 Nov 2018 14:32:37 +0100 Subject: [PATCH] device: always disconnect in nm_device_disconnect_active_connection() Previously, if @active referenced a device but was not currently queued or the current activation request, nothing was done. Now, in such a case still call nm_active_connection_set_state_fail(). Note that nm_active_connection_set_state_fail() has no effects on active-connections that are already in disconnected state (which we would expect by such an active connection). Likely there is no visible change here, but it feels more correct to ensure the active connection is always failed. --- src/devices/nm-device.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 6adf821cc4..f47331f230 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -11835,13 +11835,9 @@ nm_device_disconnect_active_connection (NMActiveConnection *active, g_return_if_fail (NM_IS_ACTIVE_CONNECTION (active)); self = nm_active_connection_get_device (active); - if (!self) { /* hm, no device? Just fail the active connection. */ - nm_active_connection_set_state_fail (active, - active_reason, - NULL); - return; + goto do_fail; } priv = NM_DEVICE_GET_PRIVATE (self); @@ -11850,15 +11846,25 @@ nm_device_disconnect_active_connection (NMActiveConnection *active, _clear_queued_act_request (priv, active_reason); 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, device_reason); } else { - /* it's going down already... */ + /* @active is the current ac of @self, but it's going down already. + * Nothing to do. */ } + return; } + + /* the active connection references this device, but it's neither the + * queued_act_request nor the current act_request. Just set it to fail... */ +do_fail: + nm_active_connection_set_state_fail (active, + active_reason, + NULL); } void