[libsoup] http2: handle nghttp2_submit_request() return value



commit 156a6c1e6e3d50410048e11fa2d8af11a13e4f23
Author: Carlos Garcia Campos <cgarcia igalia com>
Date:   Thu Jun 3 11:08:06 2021 +0200

    http2: handle nghttp2_submit_request() return value
    
    It should be checked with NGCHECK(), but we should also handle the case
    of NGHTTP2_ERR_STREAM_ID_NOT_AVAILABLE begin returned, by retrying on a
    new connection.

 libsoup/http2/soup-client-message-io-http2.c | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)
---
diff --git a/libsoup/http2/soup-client-message-io-http2.c b/libsoup/http2/soup-client-message-io-http2.c
index ecd24fe4..ef3ac8da 100644
--- a/libsoup/http2/soup-client-message-io-http2.c
+++ b/libsoup/http2/soup-client-message-io-http2.c
@@ -1163,11 +1163,18 @@ send_message_request (SoupMessage          *msg,
                 data_provider.read_callback = on_data_source_read_callback;
         }
 
-        data->stream_id = nghttp2_submit_request (io->session, &priority_spec, (const nghttp2_nv 
*)headers->data, headers->len, body_stream ? &data_provider : NULL, data);
-
-        h2_debug (io, data, "[SESSION] Request made for %s%s", authority_header, path_and_query);
-        io_try_write (io);
-
+        int32_t stream_id = nghttp2_submit_request (io->session, &priority_spec, (const nghttp2_nv 
*)headers->data, headers->len, body_stream ? &data_provider : NULL, data);
+        if (stream_id == NGHTTP2_ERR_STREAM_ID_NOT_AVAILABLE) {
+                set_error_for_data (data,
+                                    g_error_new_literal (G_IO_ERROR, G_IO_ERROR_FAILED,
+                                                         "HTTP/2 Error: stream ID not available"));
+                data->can_be_restarted = TRUE;
+        } else {
+                NGCHECK (stream_id);
+                data->stream_id = stream_id;
+                h2_debug (io, data, "[SESSION] Request made for %s%s", authority_header, path_and_query);
+                io_try_write (io);
+        }
         g_array_free (headers, TRUE);
         g_free (authority);
         g_free (host);
@@ -1406,7 +1413,7 @@ io_run_until (SoupClientMessageIOHTTP2 *io,
 
        g_object_ref (msg);
 
-       while (progress && get_io_data (msg) == io && !data->paused && data->state < state)
+       while (progress && get_io_data (msg) == io && !data->paused && !data->error && data->state < state)
                 progress = io_run (data, cancellable, &my_error);
 
         if (my_error) {
@@ -1504,6 +1511,8 @@ soup_client_message_io_http2_run_until_read_async (SoupClientMessageIO *iface,
         data->task = g_task_new (msg, cancellable, callback, user_data);
         g_task_set_priority (data->task, io_priority);
         io->pending_io_messages = g_list_prepend (io->pending_io_messages, data);
+        if (data->error)
+                soup_http2_message_data_check_status (data);
 }
 
 static gboolean


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