diff options
author | Carlos Garcia Campos <cgarcia@igalia.com> | 2022-06-28 11:59:37 +0200 |
---|---|---|
committer | Carlos Garcia Campos <cgarcia@igalia.com> | 2022-06-28 11:59:37 +0200 |
commit | af08140b549f81f8fc7c5b3d9ea4bb68af729c92 (patch) | |
tree | 1ba11aa446a3088e2776f252fef03ecdc7bcae28 | |
parent | 335da30510ad5f421c19d6c0010fe7945faa35d0 (diff) | |
download | libsoup-af08140b549f81f8fc7c5b3d9ea4bb68af729c92.tar.gz |
http2: fix runtime warnings when request fails due to IO error
(get:18601): libsoup-WARNING **: 11:25:03.814: (../libsoup/soup-session.c:318):soup_session_dispose: runtime check failed: (soup_connection_manager_get_num_conns (priv->conn_manager) == 0)
(get:18601): libsoup-WARNING **: 11:25:03.814: (../libsoup/soup-connection-manager.c:78):soup_host_free: runtime check failed: (host->conns == NULL)
This happens because we increase the in use counter of the connection
when RST_STREAM message is sent, that is decreased when the frame is
actually sent. In case of IO error, like socket timeout, we fail to send
the RST_STREAM frame, and the in use counter of the connection is not
decreased. We now process all pending closed messages when a frame fails
to be sent due to session being closed.
-rw-r--r-- | libsoup/http2/soup-client-message-io-http2.c | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/libsoup/http2/soup-client-message-io-http2.c b/libsoup/http2/soup-client-message-io-http2.c index 9d4bd694..3c524466 100644 --- a/libsoup/http2/soup-client-message-io-http2.c +++ b/libsoup/http2/soup-client-message-io-http2.c @@ -949,17 +949,45 @@ on_frame_send_callback (nghttp2_session *session, return 0; } +static gboolean +update_connection_in_use (gpointer key, + gpointer value, + SoupConnection *conn) +{ + soup_connection_set_in_use (conn, FALSE); + + return TRUE; +} + +static void +process_pending_closed_messages (SoupClientMessageIOHTTP2 *io) +{ + SoupConnection *conn = g_weak_ref_get (&io->conn); + + if (!conn) { + g_hash_table_remove_all (io->closed_messages); + return; + } + + g_hash_table_foreach_remove (io->closed_messages, (GHRFunc)update_connection_in_use, conn); + g_object_unref (conn); +} + static int on_frame_not_send_callback (nghttp2_session *session, const nghttp2_frame *frame, int lib_error_code, void *user_data) { + SoupClientMessageIOHTTP2 *io = user_data; SoupHTTP2MessageData *data = nghttp2_session_get_stream_user_data (session, frame->hd.stream_id); - h2_debug (user_data, data, "[SEND] [%s] Failed: %s", frame_type_to_string (frame->hd.type), + h2_debug (io, data, "[SEND] [%s] Failed: %s", frame_type_to_string (frame->hd.type), nghttp2_strerror (lib_error_code)); + if (lib_error_code == NGHTTP2_ERR_SESSION_CLOSING) + process_pending_closed_messages (io); + return 0; } |