From 39ab68481cf313ba8c2fe1cd92bf562607cd7754 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Thu, 27 Feb 2014 09:09:43 -0600 Subject: core: fix ActiveConnection handling of device disconnected state after e19f48ec (rh #1058843) e19f48ec was incomplete; it failed to handle device disconnections. NMDevice will clear its internal activation request *before* emitting the state change, which meant that when the NMActRequest processes the DISCONNECTED state change, the: if (NM_ACTIVE_CONNECTION (nm_device_get_act_request (device)) != active) return; statement triggered and the DISCONNECTED state change was not processed. Instead of having NMDevice keep the activation request alive over the entire DISCONNECTED state transition, which may have much greater implications, handle the special-case locally in the NMActRequest code itself. --- src/nm-activation-request.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/nm-activation-request.c b/src/nm-activation-request.c index 7ffa3dc6f5..41f1cbf63f 100644 --- a/src/nm-activation-request.c +++ b/src/nm-activation-request.c @@ -305,11 +305,22 @@ device_state_changed (NMActiveConnection *active, NMDeviceState new_state, NMDeviceState old_state) { + NMActiveConnectionState cur_ac_state = nm_active_connection_get_state (active); NMActiveConnectionState ac_state = NM_ACTIVE_CONNECTION_STATE_UNKNOWN; - /* Ignore state changes when this activation request is not yet active */ - if (NM_ACTIVE_CONNECTION (nm_device_get_act_request (device)) != active) - return; + /* Ignore state changes when this activation request is not yet active, but + * handle the DISCONNECTED state correctly. The device clears the + * activation request before sending the state change signal so this + * must be special-cased to ensure the activation request is deactivated. + */ + if (NM_ACTIVE_CONNECTION (nm_device_get_act_request (device)) != active) { + if (new_state != NM_DEVICE_STATE_DISCONNECTED) + return; + if (cur_ac_state < NM_ACTIVE_CONNECTION_STATE_ACTIVATING) + return; + + /* Catch device disconnections after this request has been active */ + } /* Set NMActiveConnection state based on the device's state */ switch (new_state) { -- cgit v1.2.1