[gnome-online-accounts/wip/rishi/simplify-cleanup: 1/3] httpclient: Simplify the clean up
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-online-accounts/wip/rishi/simplify-cleanup: 1/3] httpclient: Simplify the clean up
- Date: Tue, 27 Nov 2018 13:08:18 +0000 (UTC)
commit c0ed78702c7de43dc6ae57239a41fae46ece3ecb
Author: Debarshi Ray <debarshir gnome org>
Date: Fri Nov 23 20:14:07 2018 +0100
httpclient: Simplify the clean up
Now that the deprecated SoupSessionAsync has been replaced with
SoupSession [1], the response callbacks are invoked in the next
iteration of the main loop after soup_session_abort has returned. This
means that http_client_check_response_cb is no longer called from a
GCancellable::cancelled signal handler. Therefore, it's safe to
directly disconnect from the GCancellable in the response callback
without fearing for any deadlocks.
This reverts commit b2f94098829232bcb8294d5cefee85d5b9368f2d.
[1] Commit 6c3e3c2d2d9f6881
https://bugzilla.gnome.org/show_bug.cgi?id=764157
src/goabackend/goahttpclient.c | 38 ++++++++++----------------------------
1 file changed, 10 insertions(+), 28 deletions(-)
---
diff --git a/src/goabackend/goahttpclient.c b/src/goabackend/goahttpclient.c
index e340708c..3d3a1b95 100644
--- a/src/goabackend/goahttpclient.c
+++ b/src/goabackend/goahttpclient.c
@@ -1,6 +1,6 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
/*
- * Copyright © 2012 – 2017 Red Hat, Inc.
+ * Copyright © 2012 – 2018 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -126,6 +126,10 @@ http_client_request_started (SoupSession *session, SoupMessage *msg, SoupSocket
{
goa_utils_set_error_ssl (&error, cert_flags);
g_task_return_error (task, error);
+
+ /* The callback will be invoked after we have returned to the
+ * main loop.
+ */
soup_session_abort (data->session);
}
}
@@ -140,26 +144,19 @@ http_client_check_cancelled_cb (GCancellable *cancellable, gpointer user_data)
data = g_task_get_task_data (task);
cancelled = g_task_return_error_if_cancelled (task);
+
+ /* The callback will be invoked after we have returned to the main
+ * loop.
+ */
soup_session_abort (data->session);
g_return_if_fail (cancelled);
}
-static gboolean
-http_client_check_free_in_idle (gpointer user_data)
-{
- GTask *task = G_TASK (user_data);
-
- g_object_unref (task);
- return G_SOURCE_REMOVE;
-}
-
static void
http_client_check_response_cb (SoupSession *session, SoupMessage *msg, gpointer user_data)
{
GError *error;
- GMainContext *context;
- GSource *source;
GTask *task = G_TASK (user_data);
error = NULL;
@@ -181,22 +178,7 @@ http_client_check_response_cb (SoupSession *session, SoupMessage *msg, gpointer
g_task_return_boolean (task, TRUE);
out:
- /* We might be invoked from a GCancellable::cancelled
- * handler, and unreffing the GTask will disconnect the
- * handler. Since disconnecting from inside the handler will cause a
- * deadlock [1], we use an idle handler to break them up.
- *
- * [1] https://bugzilla.gnome.org/show_bug.cgi?id=705395
- */
-
- source = g_idle_source_new ();
- g_source_set_priority (source, G_PRIORITY_DEFAULT_IDLE);
- g_source_set_callback (source, http_client_check_free_in_idle, task, NULL);
- g_source_set_name (source, "[goa] http_client_check_free_in_idle");
-
- context = g_task_get_context (task);
- g_source_attach (source, context);
- g_source_unref (source);
+ g_object_unref (task);
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]