From e504b7fc96d57363ab8c95cb846692d5ccfb2624 Mon Sep 17 00:00:00 2001 From: Antonio Larrosa Date: Thu, 21 Mar 2019 11:32:32 +0100 Subject: [PATCH] Update connectivity value on device removal When a device is removed (like when the user unplugs a usb network device) the device object is removed, so it doesn't emit a notify signal for a change in its connectivity and so, device_connectivity_changed is not called. This means that nobody updates the global connectivity value which is potentially wrong if the device was the one providing network connectivity. Since device_connectivity_changed's first two parameters aren't actually used and are there just for the signal to be able to be connected, I moved the code from device_connectivity_changed to a new update_connectivity_value function that just takes a NMManager parameter and also call it from remove_device. [thaller@redhat.com: fix coding style regarding whitespace] https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/141 https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/101 --- src/nm-manager.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/nm-manager.c b/src/nm-manager.c index 1aada6f34..d82f671a6 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -303,6 +303,8 @@ static const GDBusSignalInfo signal_info_state_changed; static const GDBusSignalInfo signal_info_device_added; static const GDBusSignalInfo signal_info_device_removed; +static void update_connectivity_value (NMManager *self); + static gboolean add_device (NMManager *self, NMDevice *device, GError **error); static void _emit_device_added_removed (NMManager *self, @@ -1700,6 +1702,8 @@ remove_device (NMManager *self, g_signal_emit (self, signals[INTERNAL_DEVICE_REMOVED], 0, device); _notify (self, PROP_ALL_DEVICES); + update_connectivity_value (self); + nm_dbus_object_clear_and_unexport (&device); check_if_startup_complete (self); @@ -2923,6 +2927,12 @@ static void device_connectivity_changed (NMDevice *device, GParamSpec *pspec, NMManager *self) +{ + update_connectivity_value (self); +} + +static void +update_connectivity_value (NMManager *self) { NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self); NMConnectivityState best_state;