From f7c76b372c6eeaec7989fb143b3a4f7e9caf97a4 Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Mon, 18 Jan 2016 20:52:55 +0100 Subject: [PATCH] device: don't remove a devices on connection availability checks The availability checks are called from places that don't assume the device will be removed mid-air. Call the removal routine only when we're the very last thing that's being done. --- src/devices/nm-device.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 43d7b9ead5..b6eb96ca0f 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -1997,6 +1997,16 @@ unrealize_notify (NMDevice *self) * implementation. */ } +static void +available_connection_check_delete_unrealized (NMDevice *self) +{ + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + + if ( g_hash_table_size (priv->available_connections) == 0 + && !nm_device_is_real (self)) + g_signal_emit_by_name (self, NM_DEVICE_REMOVED); +} + /** * nm_device_unrealize(): * @self: the #NMDevice @@ -2094,6 +2104,7 @@ nm_device_unrealize (NMDevice *self, gboolean remove_resources, GError **error) /* Garbage-collect unneeded unrealized devices. */ nm_device_recheck_available_connections (self); + available_connection_check_delete_unrealized (self); return TRUE; } @@ -9096,16 +9107,6 @@ _del_available_connection (NMDevice *self, NMConnection *connection) return g_hash_table_remove (NM_DEVICE_GET_PRIVATE (self)->available_connections, connection); } -static void -available_connection_check_delete_unrealized (NMDevice *self) -{ - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - - if ( g_hash_table_size (priv->available_connections) == 0 - && !nm_device_is_real (self)) - g_signal_emit_by_name (self, NM_DEVICE_REMOVED); -} - static gboolean check_connection_available (NMDevice *self, NMConnection *connection, @@ -9152,8 +9153,6 @@ nm_device_recheck_available_connections (NMDevice *self) _signal_available_connections_changed (self); } - - available_connection_check_delete_unrealized (self); } /**