From f4a0ab757fca8c9ea7900f6259e8ca51a4b0a571 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Mon, 22 Aug 2016 21:37:21 +0200 Subject: libnm: make waiting objects fail when an object initialization fails Previously, when the load of an object failed and there were other objects waiting for it, those objects would remain waiting forever. Make them fail as well. --- libnm/nm-object.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'libnm') diff --git a/libnm/nm-object.c b/libnm/nm-object.c index 3b41041e24..337ca69862 100644 --- a/libnm/nm-object.c +++ b/libnm/nm-object.c @@ -488,14 +488,29 @@ create_async_complete (GObject *object, NMObjectTypeAsyncData *async_data) static void create_async_inited (GObject *object, GAsyncResult *result, gpointer user_data) { + NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (object); + NMObjectPrivate *odata_priv; NMObjectTypeAsyncData *async_data = user_data; GError *error = NULL; + ObjectCreatedData *odata; - NM_OBJECT_GET_PRIVATE (object)->inited = TRUE; + priv->inited = TRUE; if (!g_async_initable_init_finish (G_ASYNC_INITABLE (object), result, &error)) { dbgmsg ("Could not create object for %s: %s", nm_object_get_path (NM_OBJECT (object)), error->message); + + while (priv->waiters) { + odata = priv->waiters->data; + odata_priv = NM_OBJECT_GET_PRIVATE (odata->self); + + priv->waiters = g_slist_remove (priv->waiters, odata); + if (!odata_priv->reload_error) + odata_priv->reload_error = g_error_copy (error); + odata_priv->reload_remaining--; + reload_complete (odata->self, FALSE); + } + g_error_free (error); g_clear_object (&object); } @@ -503,15 +518,13 @@ create_async_inited (GObject *object, GAsyncResult *result, gpointer user_data) create_async_complete (object, async_data); if (object) { - NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (object); - /* There are some object properties whose creation couldn't proceed * because it depended on this object. */ while (priv->waiters) { - ObjectCreatedData *odata = priv->waiters->data; - + odata = priv->waiters->data; priv->waiters = g_slist_remove (priv->waiters, odata); object_property_maybe_complete (odata); + } } } -- cgit v1.2.1