67 lines
2.3 KiB
Diff
67 lines
2.3 KiB
Diff
From 2e767e2399f5049b8bb5e7d9a02c78bdb962bb26 Mon Sep 17 00:00:00 2001
|
|
From: Daniel Drake <dsd@laptop.org>
|
|
Date: Mon, 26 Nov 2012 13:09:35 -0600
|
|
Subject: [PATCH] core: don't activate uninitialized devices from udev
|
|
|
|
libgudev's device matching here by default can return devices which
|
|
udev has not yet finished initializing.
|
|
|
|
This was frequently causing boot-time races on the OLPC XO, where
|
|
NetworkManager would bring a device up before udev had renamed it,
|
|
causing the later rename to fail.
|
|
|
|
To solve this, filter the enumeration matches to only include
|
|
initialized devices. The devices that are present but uninitialized
|
|
at this time will arrive a short time later, via a uevent.
|
|
|
|
https://bugs.freedesktop.org/show_bug.cgi?id=56929
|
|
---
|
|
src/nm-udev-manager.c | 14 ++++++++++++--
|
|
1 file changed, 12 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/src/nm-udev-manager.c b/src/nm-udev-manager.c
|
|
index 792e53b..60f41aa 100644
|
|
--- a/src/nm-udev-manager.c
|
|
+++ b/src/nm-udev-manager.c
|
|
@@ -515,25 +515,35 @@ void
|
|
nm_udev_manager_query_devices (NMUdevManager *self)
|
|
{
|
|
NMUdevManagerPrivate *priv = NM_UDEV_MANAGER_GET_PRIVATE (self);
|
|
+ GUdevEnumerator *enumerator;
|
|
GList *devices, *iter;
|
|
|
|
g_return_if_fail (self != NULL);
|
|
g_return_if_fail (NM_IS_UDEV_MANAGER (self));
|
|
|
|
- devices = g_udev_client_query_by_subsystem (priv->client, "net");
|
|
+ enumerator = g_udev_enumerator_new (priv->client);
|
|
+ g_udev_enumerator_add_match_subsystem (enumerator, "net");
|
|
+ g_udev_enumerator_add_match_is_initialized (enumerator);
|
|
+
|
|
+ devices = g_udev_enumerator_execute (enumerator);
|
|
for (iter = devices; iter; iter = g_list_next (iter)) {
|
|
net_add (self, G_UDEV_DEVICE (iter->data));
|
|
g_object_unref (G_UDEV_DEVICE (iter->data));
|
|
}
|
|
g_list_free (devices);
|
|
+ g_object_unref (enumerator);
|
|
|
|
|
|
- devices = g_udev_client_query_by_subsystem (priv->client, "atm");
|
|
+ enumerator = g_udev_enumerator_new (priv->client);
|
|
+ g_udev_enumerator_add_match_subsystem (enumerator, "atm");
|
|
+ g_udev_enumerator_add_match_is_initialized (enumerator);
|
|
+ devices = g_udev_enumerator_execute (enumerator);
|
|
for (iter = devices; iter; iter = g_list_next (iter)) {
|
|
adsl_add (self, G_UDEV_DEVICE (iter->data));
|
|
g_object_unref (G_UDEV_DEVICE (iter->data));
|
|
}
|
|
g_list_free (devices);
|
|
+ g_object_unref (enumerator);
|
|
}
|
|
|
|
static void
|
|
--
|
|
1.7.11.7
|
|
|