[libsoup/carlosgc/http2-reset-closed-stream: 1/2] http2: finish the message IO when request is cancelled




commit edcc9eb6f47cc76d871951bf67b8e00e0c897460
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 498b3e69..cb4c65d7 100644
--- a/libsoup/http2/soup-client-message-io-http2.c
+++ b/libsoup/http2/soup-client-message-io-http2.c
@@ -217,6 +217,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 be7fc43a..c11b245e 100644
--- a/tests/http2-test.c
+++ b/tests/http2-test.c
@@ -247,12 +247,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 = 10; i; i--)
-                g_main_context_iteration (async_context, TRUE);
-
-        /* 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]