diff --git a/libnm/nm-manager.c b/libnm/nm-manager.c index 8d78d221bc..fc558620c7 100644 --- a/libnm/nm-manager.c +++ b/libnm/nm-manager.c @@ -743,6 +743,8 @@ typedef struct { char *new_connection_path; } ActivateInfo; +static void active_removed (NMObject *object, NMActiveConnection *active, gpointer user_data); + static void activate_info_complete (ActivateInfo *info, NMActiveConnection *active, @@ -750,6 +752,7 @@ activate_info_complete (ActivateInfo *info, { NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (info->manager); + g_signal_handlers_disconnect_by_func (info->manager, G_CALLBACK (active_removed), info); if (active) g_simple_async_result_set_op_res_gpointer (info->simple, g_object_ref (active), g_object_unref); else @@ -836,6 +839,22 @@ activation_cancelled (GCancellable *cancellable, g_clear_error (&error); } +static void +active_removed (NMObject *object, NMActiveConnection *active, gpointer user_data) +{ + ActivateInfo *info = user_data; + GError *error = NULL; + + if (strcmp (info->active_path, nm_object_get_path (NM_OBJECT (active)))) + return; + + error = g_error_new_literal (NM_CLIENT_ERROR, + NM_CLIENT_ERROR_FAILED, + _("Active connection could not be attached to the device")); + activate_info_complete (info, NULL, error); + g_clear_error (&error); +} + static void activate_cb (GObject *object, GAsyncResult *result, @@ -852,6 +871,9 @@ activate_cb (GObject *object, G_CALLBACK (activation_cancelled), info); } + g_signal_connect (info->manager, "active-connection-removed", + G_CALLBACK (active_removed), info); + recheck_pending_activations (info->manager); } else { g_dbus_error_strip_remote_error (error);