[libsoup/wip/http2] body-input-stream-http2: try to read after emitting need-more-data signal
- From: Carlos Garcia Campos <carlosgc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsoup/wip/http2] body-input-stream-http2: try to read after emitting need-more-data signal
- Date: Mon, 17 May 2021 13:36:04 +0000 (UTC)
commit 049fe6a2574190d45779ae42f30fc25ae2406221
Author: Carlos Garcia Campos <cgarcia igalia com>
Date: Mon May 17 15:22:56 2021 +0200
body-input-stream-http2: try to read after emitting need-more-data signal
We might have the data already available, the stream can even be
completed at this point.
libsoup/http2/soup-body-input-stream-http2.c | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
---
diff --git a/libsoup/http2/soup-body-input-stream-http2.c b/libsoup/http2/soup-body-input-stream-http2.c
index 3fcc43e4..8c7fe2cc 100644
--- a/libsoup/http2/soup-body-input-stream-http2.c
+++ b/libsoup/http2/soup-body-input-stream-http2.c
@@ -216,19 +216,31 @@ soup_body_input_stream_http2_read_nonblocking (GPollableInputStream *stream,
gsize read = soup_body_input_stream_http2_read_real (G_INPUT_STREAM (stream), FALSE, buffer, count,
NULL, &inner_error);
if (read == 0 && !priv->completed && !inner_error) {
- g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK, "Operation would block");
-
/* Try requesting more reads from the io backend */
GError *inner_error = NULL;
+
g_signal_emit (memory_stream, signals[NEED_MORE_DATA], 0,
NULL, FALSE, &inner_error);
- // TODO: Do we care?
- g_clear_error (&inner_error);
+ if (inner_error) {
+ g_propagate_error (error, inner_error);
return -1;
}
+ if (priv->completed)
+ return soup_body_input_stream_http2_read_real (G_INPUT_STREAM (stream), FALSE,
buffer, count, NULL, error);
+
+ if (priv->pos < priv->len) {
+ read = soup_body_input_stream_http2_read_real (G_INPUT_STREAM (stream), FALSE,
buffer, count, NULL, NULL);
+ if (read > 0)
+ return read;
+ }
+
+ g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK, "Operation would block");
+ return -1;
+ }
+
if (inner_error)
g_propagate_error (error, inner_error);
@@ -569,4 +581,4 @@ soup_body_input_stream_http2_class_init (SoupBodyInputStreamHttp2Class *klass)
NULL,
G_TYPE_ERROR,
2, G_TYPE_CANCELLABLE, G_TYPE_BOOLEAN);
-}
\ No newline at end of file
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]