Re: [PATCH] core: don't activate uninitialized devices from udev
- From: Dan Williams <dcbw redhat com>
- To: Daniel Drake <dsd laptop org>
- Cc: networkmanager-list gnome org
- Subject: Re: [PATCH] core: don't activate uninitialized devices from udev
- Date: Mon, 26 Nov 2012 16:12:03 -0600
On Mon, 2012-11-26 at 15:02 -0500, Daniel Drake wrote:
> When enumerating devices, libgudev's matching by default will 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
Applied, thanks! Also updated the configure.ac check for gudev to >=
165, which is where the Enumerator stuff debuted. udev 165 was released
on Dec 17 2010, almost two years ago, which should be old enough for
everyone to pick it up. If there are issues with that dependency, we
can always add back the old codepath in parallel for older udev
versions.
Dan
> ---
> 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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]