diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2016-11-16 11:46:29 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2016-11-24 14:12:33 +0100 |
commit | ad4d3ba008e74f46f18905eb4c28295bf436bc3b (patch) | |
tree | a6d803ad1c6007458f22e14e35b085ce8ee055bc | |
parent | 561a0a428d1d2ba678788e645f1ce52263ad8ac5 (diff) | |
download | NetworkManager-ad4d3ba008e74f46f18905eb4c28295bf436bc3b.tar.gz |
manager: fix state transition on resuming from sleep
When going to sleep, we unmanage devices setting the unmanaged flags
immediately but delaying the state transition (because we do it from
another state transition). The signal handler can be executed after
the wake and, especially, after we have already re-managed the device,
making the device unmanaged again.
Detect such situation and force the state to UNMANAGED (which will
also clear any pending state change), so that later we manage the
device again and it will try to activate any available connection.
Fixes: 81ea812362de2757979e2c675774fc445400c59f
(cherry picked from commit 3cc06c3db679c1ff2f61a301396393300d36adbb)
-rw-r--r-- | src/nm-manager.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/nm-manager.c b/src/nm-manager.c index f49248a8aa..ad1e48e85e 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -4061,16 +4061,26 @@ do_sleep_wake (NMManager *self, gboolean sleeping_changed) if (waking_from_suspend) { sleep_devices_clear (self); - /* Belatedly take down Wake-on-LAN devices; ideally we wouldn't have to do this - * but for now it's the only way to make sure we re-check their connectivity. - */ for (iter = priv->devices; iter; iter = iter->next) { NMDevice *device = iter->data; if (nm_device_is_software (device)) continue; + + /* Belatedly take down Wake-on-LAN devices; ideally we wouldn't have to do this + * but for now it's the only way to make sure we re-check their connectivity. + */ if (device_is_wake_on_lan (device)) nm_device_set_unmanaged_by_flags (device, NM_UNMANAGED_SLEEPING, TRUE, NM_DEVICE_STATE_REASON_SLEEPING); + + /* Check if the device is unmanaged but the state transition is still pending. + * If so, change state now so that later we re-manage the device forcing a + * re-check of available connections. + */ + if ( !nm_device_get_managed (device, FALSE) + && nm_device_get_state (device) != NM_DEVICE_STATE_UNMANAGED) { + nm_device_state_changed (device, NM_DEVICE_STATE_UNMANAGED, NM_DEVICE_STATE_REASON_SLEEPING); + } } } |