[gnome-online-accounts/wip/rishi/gtask: 4/4] httpclient: Simplify the clean up



commit aec454c01c8fb531fd6a998027840acdc7f2514e
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

 src/goabackend/goahttpclient.c | 28 +---------------------------
 1 file changed, 1 insertion(+), 27 deletions(-)
---
diff --git a/src/goabackend/goahttpclient.c b/src/goabackend/goahttpclient.c
index e340708c..d2e79ecf 100644
--- a/src/goabackend/goahttpclient.c
+++ b/src/goabackend/goahttpclient.c
@@ -145,21 +145,10 @@ http_client_check_cancelled_cb (GCancellable *cancellable, gpointer user_data)
   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 +170,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]