From 8bbe61206fdc5cbf251da51440b4e041a02d641f Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Fri, 6 Jul 2018 21:35:04 +0200 Subject: [PATCH] manager: update the device state file upon (dis)connection Update the device state file every time the device is connected, disconnected, or becomes unmanaged. In this way, NM becomes more robust against crashes or forced terminations because it can resume the previous device state seamlessly. --- src/nm-manager.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/nm-manager.c b/src/nm-manager.c index b4c2b08fe0..eeaefccb45 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -1471,6 +1471,12 @@ manager_device_state_changed (NMDevice *device, break; } + if (NM_IN_SET (new_state, + NM_DEVICE_STATE_UNMANAGED, + NM_DEVICE_STATE_DISCONNECTED, + NM_DEVICE_STATE_ACTIVATED)) + nm_manager_write_device_state (self, device); + if ( new_state == NM_DEVICE_STATE_UNAVAILABLE || new_state == NM_DEVICE_STATE_DISCONNECTED) nm_settings_device_added (priv->settings, device);