[libsoup/libsoup-3-0] http2: always try to write before every read
- From: Carlos Garcia Campos <carlosgc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsoup/libsoup-3-0] http2: always try to write before every read
- Date: Fri, 2 Sep 2022 10:20:31 +0000 (UTC)
commit a99b7ac9801af44359c372083ce0ac519cd71d80
Author: Carlos Garcia Campos <cgarcia igalia com>
Date: Wed Aug 31 14:35:40 2022 +0200
http2: always try to write before every read
It can happen that an error handled by nghttp2 generates a reset stream
frame that needs to be sent, so we need to try to write even if we haven't
made any explict call that requires writing. Also give more priority to
write source than read source.
Fixes #298
libsoup/http2/soup-client-message-io-http2.c | 6 ++++++
1 file changed, 6 insertions(+)
---
diff --git a/libsoup/http2/soup-client-message-io-http2.c b/libsoup/http2/soup-client-message-io-http2.c
index 7e6fc64a..7148e602 100644
--- a/libsoup/http2/soup-client-message-io-http2.c
+++ b/libsoup/http2/soup-client-message-io-http2.c
@@ -470,6 +470,8 @@ io_try_write (SoupClientMessageIOHTTP2 *io,
g_clear_error (&error);
io->write_source = g_pollable_output_stream_create_source (G_POLLABLE_OUTPUT_STREAM
(io->ostream), NULL);
g_source_set_name (io->write_source, "Soup HTTP/2 write source");
+ /* Give write more priority than read */
+ g_source_set_priority (io->write_source, G_PRIORITY_DEFAULT - 1);
g_source_set_callback (io->write_source, (GSourceFunc)io_write_ready, io, NULL);
g_source_attach (io->write_source, g_main_context_get_thread_default ());
}
@@ -488,6 +490,9 @@ io_read (SoupClientMessageIOHTTP2 *io,
gssize read;
int ret;
+ /* Always try to write before read, in case there's a pending reset stream after an error. */
+ io_try_write (io, blocking);
+
if ((read = g_pollable_stream_read (io->istream, buffer, sizeof (buffer),
blocking, cancellable, error)) < 0)
return FALSE;
@@ -1898,6 +1903,7 @@ soup_client_message_io_http2_new (SoupConnection *conn)
io->read_source = g_pollable_input_stream_create_source (G_POLLABLE_INPUT_STREAM (io->istream),
NULL);
g_source_set_name (io->read_source, "Soup HTTP/2 read source");
+ g_source_set_priority (io->read_source, G_PRIORITY_DEFAULT);
g_source_set_callback (io->read_source, (GSourceFunc)io_read_ready, io, NULL);
g_source_attach (io->read_source, g_main_context_get_thread_default ());
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]