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.
This commit is contained in:
Beniamino Galvani 2018-07-06 21:35:04 +02:00
parent 060f2138ee
commit 8bbe61206f

View file

@ -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);