From f4a0ab757fca8c9ea7900f6259e8ca51a4b0a571 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Mon, 22 Aug 2016 21:37:21 +0200 Subject: [PATCH 1/2] 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(-) 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); + } } } From 79a357b07a2d038ddd8ee08a65a3996d0e9d7a69 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Thu, 25 Aug 2016 21:07:24 +0200 Subject: [PATCH 2/2] cli: connections: fail the activation if the ac deactivates Since commit ac888de15103 ("cli/connections: fail the activation when the active connection disappears") we rely only on the disappearing of the active-connection to determine the failure of an activation. libnm can collapse a 'added' and a 'removed' signal if they are received closer enough and thus we may miss the removal of the active connection. Restore the detection of failure based on active-connection state. --- clients/cli/connections.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/clients/cli/connections.c b/clients/cli/connections.c index ea7c8a79df..3e85ca5bd8 100644 --- a/clients/cli/connections.c +++ b/clients/cli/connections.c @@ -2178,6 +2178,10 @@ active_connection_state_cb (NMActiveConnection *active, GParamSpec *pspec, Activ g_print (_("Connection successfully activated (D-Bus active path: %s)\n"), nm_object_get_path (NM_OBJECT (active))); activate_connection_info_finish (info); + } else if (state == NM_ACTIVE_CONNECTION_STATE_DEACTIVATED) { + g_string_printf (nmc->return_text, _("Error: Connection activation failed.")); + nmc->return_value = NMC_RESULT_ERROR_CON_ACTIVATION; + activate_connection_info_finish (info); } else if (state == NM_ACTIVE_CONNECTION_STATE_ACTIVATING) { /* activating master connection does not automatically activate any slaves, so their * active connection state will not progress beyond ACTIVATING state.