[libsoup/wip/http2] fixup! Add initial HTTP2 backend
- From: Patrick Griffis <pgriffis src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsoup/wip/http2] fixup! Add initial HTTP2 backend
- Date: Fri, 14 May 2021 16:34:13 +0000 (UTC)
commit 16b58daa3353e3a16bdfca5cc00d9eff783a9e9c
Author: Patrick Griffis <pgriffis igalia com>
Date: Fri May 14 11:27:34 2021 -0500
fixup! Add initial HTTP2 backend
libsoup/http2/soup-client-message-io-http2.c | 22 +++++++++++++++-------
libsoup/http2/soup-client-message-io-http2.h | 3 ++-
libsoup/soup-connection.c | 2 +-
3 files changed, 18 insertions(+), 9 deletions(-)
---
diff --git a/libsoup/http2/soup-client-message-io-http2.c b/libsoup/http2/soup-client-message-io-http2.c
index 63f69b73..c5a3f857 100644
--- a/libsoup/http2/soup-client-message-io-http2.c
+++ b/libsoup/http2/soup-client-message-io-http2.c
@@ -66,6 +66,7 @@ typedef struct {
GIOStream *stream;
GInputStream *istream;
GOutputStream *ostream;
+ guint64 connection_id;
GMainContext *async_context;
@@ -168,7 +169,7 @@ h2_debug (SoupClientMessageIOHTTP2 *io,
stream_id = data->stream_id;
g_assert (io);
- g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "[C%p-S%u] %s", io->stream, stream_id, message);
+ g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "[C%" G_GUINT64_FORMAT "-S%u] %s", io->connection_id,
stream_id, message);
g_free (message);
}
@@ -1270,12 +1271,18 @@ soup_client_message_io_http2_is_open (SoupClientMessageIO *iface)
SoupClientMessageIOHTTP2 *io = (SoupClientMessageIOHTTP2 *)iface;
gboolean ret = TRUE;
- GError *error = NULL;
- if (!io_read (io, FALSE, NULL, &error)) {
- if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK))
- ret = FALSE;
+ /* Check directly if the session is closed */
+ if (!nghttp2_session_want_read (io->session) && !nghttp2_session_want_write (io->session))
+ ret = FALSE;
+ else {
+ /* Otherwise test if reading from the socket fails */
+ GError *error = NULL;
+ if (!io_read (io, FALSE, NULL, &error)) {
+ if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK))
+ ret = FALSE;
- g_clear_error (&error);
+ g_clear_error (&error);
+ }
}
h2_debug (io, NULL, "[SESSION] Open=%d", ret);
@@ -1346,7 +1353,7 @@ soup_client_message_io_http2_init (SoupClientMessageIOHTTP2 *io)
#define MAX_HEADER_TABLE_SIZE 65536 /* Match size used by Chromium/Firefox */
SoupClientMessageIO *
-soup_client_message_io_http2_new (GIOStream *stream)
+soup_client_message_io_http2_new (GIOStream *stream, guint64 connection_id)
{
SoupClientMessageIOHTTP2 *io = g_new0 (SoupClientMessageIOHTTP2, 1);
soup_client_message_io_http2_init (io);
@@ -1354,6 +1361,7 @@ soup_client_message_io_http2_new (GIOStream *stream)
io->stream = g_object_ref (stream);
io->istream = g_io_stream_get_input_stream (io->stream);
io->ostream = g_io_stream_get_output_stream (io->stream);
+ io->connection_id = connection_id;
io->async_context = g_main_context_ref_thread_default ();
diff --git a/libsoup/http2/soup-client-message-io-http2.h b/libsoup/http2/soup-client-message-io-http2.h
index dc6b284b..213c38f3 100644
--- a/libsoup/http2/soup-client-message-io-http2.h
+++ b/libsoup/http2/soup-client-message-io-http2.h
@@ -9,6 +9,7 @@
G_BEGIN_DECLS
-SoupClientMessageIO *soup_client_message_io_http2_new (GIOStream *stream);
+SoupClientMessageIO *soup_client_message_io_http2_new (GIOStream *stream,
+ guint64 connection_id);
G_END_DECLS
diff --git a/libsoup/soup-connection.c b/libsoup/soup-connection.c
index feae24cc..b4fd0a1d 100644
--- a/libsoup/soup-connection.c
+++ b/libsoup/soup-connection.c
@@ -1133,7 +1133,7 @@ soup_connection_setup_message_io (SoupConnection *conn,
} else {
if (!priv->io_data || !soup_client_message_io_is_reusable (priv->io_data)) {
g_clear_pointer (&priv->io_data, soup_client_message_io_destroy);
- priv->io_data = soup_client_message_io_http2_new (priv->iostream);
+ priv->io_data = soup_client_message_io_http2_new (priv->iostream, priv->id);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]