[libsoup/libsoup-3-0] http2: finish the message IO when request is cancelled



commit cc91759dbb011b59a872670d3bb789214d9201f0
Author: Carlos Garcia Campos <cgarcia igalia com>
Date:   Tue Aug 30 12:18:28 2022 +0200

    http2: finish the message IO when request is cancelled

 libsoup/http2/soup-client-message-io-http2.c | 1 +
 tests/http2-test.c                           | 8 ++------
 2 files changed, 3 insertions(+), 6 deletions(-)
---
diff --git a/libsoup/http2/soup-client-message-io-http2.c b/libsoup/http2/soup-client-message-io-http2.c
index b05fe299..48ba7d5c 100644
--- a/libsoup/http2/soup-client-message-io-http2.c
+++ b/libsoup/http2/soup-client-message-io-http2.c
@@ -314,6 +314,7 @@ soup_http2_message_data_check_status (SoupHTTP2MessageData *data)
         if (g_cancellable_set_error_if_cancelled (g_task_get_cancellable (task), &error)) {
                 io->pending_io_messages = g_list_remove (io->pending_io_messages, data);
                 data->task = NULL;
+                soup_client_message_io_http2_finished ((SoupClientMessageIO *)io, msg);
                 g_task_return_error (task, error);
                 g_object_unref (task);
                 return;
diff --git a/tests/http2-test.c b/tests/http2-test.c
index 689fa2f5..b0e5bbc2 100644
--- a/tests/http2-test.c
+++ b/tests/http2-test.c
@@ -217,12 +217,8 @@ do_cancellation_test (Test *test, gconstpointer data)
         soup_session_send_and_read_async (test->session, msg, G_PRIORITY_DEFAULT, cancellable,
                                           (GAsyncReadyCallback)on_send_and_read_cancelled_complete, &done);
 
-        /* Just iterate until a partial read is happening */
-        for (guint i = 100000; i; i--)
-                g_main_context_iteration (async_context, FALSE);
-
-        /* Then cancel everything */
-        g_cancellable_cancel (cancellable);
+        /* Cancel right after getting the headers */
+        g_signal_connect_swapped (msg, "got-headers", G_CALLBACK (g_cancellable_cancel), cancellable);
 
         while (!done)
                 g_main_context_iteration (async_context, FALSE);


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