device: don't remove a devices on connection availability checks
authorLubomir Rintel <lkundrak@v3.sk>
Mon, 18 Jan 2016 19:52:55 +0000 (20:52 +0100)
committerLubomir Rintel <lkundrak@v3.sk>
Mon, 18 Jan 2016 20:09:28 +0000 (21:09 +0100)
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

index 43d7b9e..b6eb96c 100644 (file)
@@ -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);
 }
 
 /**