[libsoup] http2-io: try to write after receiving a window update frame



commit 6c620d9563ecfea0ca5d5aa2cabf95130b4feb85
Author: Carlos Garcia Campos <cgarcia igalia com>
Date:   Wed Jun 23 13:52:49 2021 +0200

    http2-io: try to write after receiving a window update frame
    
    It could be that the previous frame to send was deferred by nghttp2
    because remote window size was 0. So, if we get a window update frame
    with a window size > 0, we try to write to continue any possible resumed
    frame.

 libsoup/http2/soup-client-message-io-http2.c | 40 ++++++++++++++++++++--------
 1 file changed, 29 insertions(+), 11 deletions(-)
---
diff --git a/libsoup/http2/soup-client-message-io-http2.c b/libsoup/http2/soup-client-message-io-http2.c
index 334fb8be..592fde68 100644
--- a/libsoup/http2/soup-client-message-io-http2.c
+++ b/libsoup/http2/soup-client-message-io-http2.c
@@ -630,23 +630,35 @@ on_frame_recv_callback (nghttp2_session     *session,
                         gpointer             user_data)
 {
         SoupClientMessageIOHTTP2 *io = user_data;
-        SoupHTTP2MessageData *data = nghttp2_session_get_stream_user_data (session, frame->hd.stream_id);
+        SoupHTTP2MessageData *data;
 
-        h2_debug (io, data, "[RECV] [%s] Recieved (%u)", frame_type_to_string (frame->hd.type), 
frame->hd.flags);
+        if (frame->hd.stream_id == 0) {
+                h2_debug (io, NULL, "[RECV] [%s] Recieved (%u)", frame_type_to_string (frame->hd.type), 
frame->hd.flags);
+
+                switch (frame->hd.type) {
+                case NGHTTP2_GOAWAY:
+                        h2_debug (io, NULL, "[RECV] GOAWAY: error=%s, last_stream_id=%d %s",
+                                  nghttp2_http2_strerror (frame->goaway.error_code),
+                                  frame->goaway.last_stream_id,
+                                  frame->goaway.opaque_data ? (char *)frame->goaway.opaque_data : "");
+                        handle_goaway (io, frame->goaway.error_code, frame->goaway.last_stream_id);
+                        io->is_shutdown = TRUE;
+                        soup_client_message_io_http2_terminate_session (io);
+                        break;
+                case NGHTTP2_WINDOW_UPDATE:
+                        h2_debug (io, NULL, "[RECV] WINDOW_UPDATE: increment=%d, total=%d", 
frame->window_update.window_size_increment,
+                                  nghttp2_session_get_remote_window_size (session));
+                        break;
+                }
 
-        if (frame->hd.type == NGHTTP2_GOAWAY) {
-                h2_debug (io, data, "[RECV] GOAWAY: error=%s, last_stream_id=%d %s",
-                          nghttp2_http2_strerror (frame->goaway.error_code),
-                          frame->goaway.last_stream_id,
-                          frame->goaway.opaque_data ? (char *)frame->goaway.opaque_data : "");
-                handle_goaway (io, frame->goaway.error_code, frame->goaway.last_stream_id);
-                io->is_shutdown = TRUE;
-                soup_client_message_io_http2_terminate_session (io);
                 return 0;
         }
 
+        data = nghttp2_session_get_stream_user_data (session, frame->hd.stream_id);
+        h2_debug (io, data, "[RECV] [%s] Recieved (%u)", frame_type_to_string (frame->hd.type), 
frame->hd.flags);
+
         if (!data) {
-                if (frame->hd.stream_id != 0 && !(frame->hd.flags & NGHTTP2_FLAG_END_STREAM))
+                if (!(frame->hd.flags & NGHTTP2_FLAG_END_STREAM))
                         g_warn_if_reached ();
                 return 0;
         }
@@ -691,6 +703,12 @@ on_frame_recv_callback (nghttp2_session     *session,
                                                                        nghttp2_http2_strerror 
(frame->rst_stream.error_code)));
                 }
                 break;
+        case NGHTTP2_WINDOW_UPDATE:
+                h2_debug (io, data, "[RECV] WINDOW_UPDATE: increment=%d, total=%d", 
frame->window_update.window_size_increment,
+                          nghttp2_session_get_stream_remote_window_size (session, frame->hd.stream_id));
+                if (nghttp2_session_get_stream_remote_window_size (session, frame->hd.stream_id) > 0)
+                        io_try_write (io);
+                break;
         };
 
         return 0;


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