[libsoup/carlosgc/thread-safe: 8/21] http2: do not perform sync IO when body stream needs more data




commit f495a5e20b90036ee003c203bdf6bb8dd5d801b8
Author: Carlos Garcia Campos <cgarcia igalia com>
Date:   Mon Apr 18 15:16:54 2022 +0200

    http2: do not perform sync IO when body stream needs more data
    
    Add blocking parameter to SoupBodyInputStreamHttp2::need-more-data and
    only do sync IO when input stream read is blocking too.

 libsoup/http2/soup-body-input-stream-http2.c | 5 +++--
 libsoup/http2/soup-client-message-io-http2.c | 3 ++-
 2 files changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/libsoup/http2/soup-body-input-stream-http2.c b/libsoup/http2/soup-body-input-stream-http2.c
index 2795772a..a28838ab 100644
--- a/libsoup/http2/soup-body-input-stream-http2.c
+++ b/libsoup/http2/soup-body-input-stream-http2.c
@@ -180,7 +180,7 @@ soup_body_input_stream_http2_read_real (GInputStream  *stream,
         if (count == 0 && blocking && !priv->completed) {
                 GError *read_error = NULL;
                 g_signal_emit (memory_stream, signals[NEED_MORE_DATA], 0,
-                               cancellable, &read_error);
+                               blocking, cancellable, &read_error);
 
                 if (read_error) {
                         g_propagate_error (error, read_error);
@@ -429,5 +429,6 @@ soup_body_input_stream_http2_class_init (SoupBodyInputStreamHttp2Class *klass)
                               NULL, NULL,
                               NULL,
                               G_TYPE_ERROR,
-                              1, G_TYPE_CANCELLABLE);
+                              2, G_TYPE_BOOLEAN,
+                              G_TYPE_CANCELLABLE);
 }
diff --git a/libsoup/http2/soup-client-message-io-http2.c b/libsoup/http2/soup-client-message-io-http2.c
index 3164fa06..735f9319 100644
--- a/libsoup/http2/soup-client-message-io-http2.c
+++ b/libsoup/http2/soup-client-message-io-http2.c
@@ -589,6 +589,7 @@ on_header_callback (nghttp2_session     *session,
 
 static GError *
 memory_stream_need_more_data_callback (SoupBodyInputStreamHttp2 *stream,
+                                       gboolean                  blocking,
                                        GCancellable             *cancellable,
                                        gpointer                  user_data)
 {
@@ -596,7 +597,7 @@ memory_stream_need_more_data_callback (SoupBodyInputStreamHttp2 *stream,
         GError *error = NULL;
 
         if (nghttp2_session_want_read (data->io->session))
-                io_read (data->io, TRUE, cancellable, &error);
+                io_read (data->io, blocking, cancellable, &error);
 
         return error;
 }


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