[libsoup] soup-session: use SoupMessageQueueItem's cancellable for the GTask



commit e91d1962451116a8d7ce1a7b0031095482bfe4a9
Author: Sergio Villar Senin <svillar igalia com>
Date:   Wed Jan 30 19:25:12 2013 +0100

    soup-session: use SoupMessageQueueItem's cancellable for the GTask
    
    Even if the caller does not specify a GCancellable the GTask must use the
    one that comes with the item by default.
    
    This also sets check_cancellable() to FALSE in the session's GTask in order
    not to override error messages previously set on the GTask in case of
    cancellations.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=692310

 libsoup/soup-session.c |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/libsoup/soup-session.c b/libsoup/soup-session.c
index ab9e2cd..bc23e88 100644
--- a/libsoup/soup-session.c
+++ b/libsoup/soup-session.c
@@ -3894,15 +3894,23 @@ soup_session_send_async (SoupSession         *session,
 	g_signal_connect (msg, "finished",
 			  G_CALLBACK (async_send_request_finished), item);
 
-	item->new_api = TRUE;
-	item->task = g_task_new (session, cancellable, callback, user_data);
-	g_task_set_task_data (item->task, item, (GDestroyNotify) soup_message_queue_item_unref);
-
 	if (cancellable) {
 		g_object_unref (item->cancellable);
 		item->cancellable = g_object_ref (cancellable);
 	}
 
+	item->new_api = TRUE;
+	item->task = g_task_new (session, item->cancellable, callback, user_data);
+	g_task_set_task_data (item->task, item, (GDestroyNotify) soup_message_queue_item_unref);
+
+	/* Do not check for cancellations as we do not want to
+	 * overwrite custom error messages set during cancellations
+	 * (for example SOUP_HTTP_ERROR is set for cancelled messages
+	 * in async_send_request_return_result() (status_code==1
+	 * means CANCEL and is considered a TRANSPORT_ERROR)).
+	 */
+	g_task_set_check_cancellable (item->task, FALSE);
+
 	if (async_respond_from_cache (session, item))
 		item->state = SOUP_MESSAGE_CACHED;
 	else



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]