summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntonio Larrosa <alarrosa@suse.com>2019-03-21 11:32:32 +0100
committerThomas Haller <thaller@redhat.com>2019-04-02 17:19:31 +0200
commite504b7fc96d57363ab8c95cb846692d5ccfb2624 (patch)
treefa2912452551421ad7fb7f8d7e32c6b3e15c479e
parentaba01d3d8a9856d0984b9415313bf39859b32a38 (diff)
downloadNetworkManager-e504b7fc96d57363ab8c95cb846692d5ccfb2624.tar.gz
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
-rw-r--r--src/nm-manager.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/nm-manager.c b/src/nm-manager.c
index 1aada6f347..d82f671a6b 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);
@@ -2924,6 +2928,12 @@ 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;