[libsoup/carlosgc/send-after-cancel] http2: return early on send headers or data after cancellation




commit 77f46a88084006f491617f84f85178ed5879a825
Author: Carlos Garcia Campos <cgarcia igalia com>
Date:   Wed Sep 21 13:01:23 2022 +0200

    http2: return early on send headers or data after cancellation
    
    Fixes #299

 libsoup/http2/soup-client-message-io-http2.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/libsoup/http2/soup-client-message-io-http2.c b/libsoup/http2/soup-client-message-io-http2.c
index 86d3f3ae..9cffd641 100644
--- a/libsoup/http2/soup-client-message-io-http2.c
+++ b/libsoup/http2/soup-client-message-io-http2.c
@@ -830,11 +830,15 @@ on_frame_send_callback (nghttp2_session     *session,
 
         switch (frame->hd.type) {
         case NGHTTP2_HEADERS:
-                g_assert (data);
                 h2_debug (io, data, "[SEND] [HEADERS] category=%s finished=%d",
                           soup_http2_headers_category_to_string (frame->headers.cat),
                           (frame->hd.flags & NGHTTP2_FLAG_END_HEADERS) ? 1 : 0);
 
+                if (!data) {
+                        /* This can happen in case of cancellation */
+                        return;
+                }
+
                 if (data->metrics)
                         data->metrics->request_header_bytes_sent += frame->hd.length + FRAME_HEADER_SIZE;
 
@@ -847,7 +851,11 @@ on_frame_send_callback (nghttp2_session     *session,
                 }
                 break;
         case NGHTTP2_DATA:
-                g_assert (data);
+                if (!data) {
+                        /* This can happen in case of cancellation */
+                        return;
+                }
+
                 if (data->state < STATE_WRITE_DATA)
                         advance_state_from (data, STATE_WRITE_HEADERS, STATE_WRITE_DATA);
 


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