diff options
author | Carlos Garcia Campos <cgarcia@igalia.com> | 2021-05-30 08:50:49 +0200 |
---|---|---|
committer | Carlos Garcia Campos <cgarcia@igalia.com> | 2021-05-31 11:58:04 +0200 |
commit | 3357288cec5471614351e9ef23bdf2fd98e2ab58 (patch) | |
tree | 6e11ac4978b4e739c22e3327fae2e6706d00bda3 /tests/http2-body-stream-test.c | |
parent | c8cbfd4b49888d0a2f3dc03fadee6c8d64fd5631 (diff) | |
download | libsoup-3357288cec5471614351e9ef23bdf2fd98e2ab58.tar.gz |
io-http2: simplify async io handling
Use a global polling source for reading and process any pending io
operation after every successful read. Every time we submit data to the
session we try to write, using a single global polling source in case
the operation would block until everything is written. This simplifies
the io handling and avoids the creation and destruction of a lot of
polling sources.
Diffstat (limited to 'tests/http2-body-stream-test.c')
-rw-r--r-- | tests/http2-body-stream-test.c | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/tests/http2-body-stream-test.c b/tests/http2-body-stream-test.c index e5aa3007..ee3218bc 100644 --- a/tests/http2-body-stream-test.c +++ b/tests/http2-body-stream-test.c @@ -26,8 +26,7 @@ do_large_data_test (void) #define CHUNK_SIZE (gsize)1024 * 1024 * 512 // 512 MiB #define TEST_SIZE CHUNK_SIZE * 20 // 10 GiB - GInputStream *parent_stream = g_memory_input_stream_new (); - GInputStream *stream = soup_body_input_stream_http2_new (G_POLLABLE_INPUT_STREAM (parent_stream)); + GInputStream *stream = soup_body_input_stream_http2_new (); SoupBodyInputStreamHttp2 *mem_stream = SOUP_BODY_INPUT_STREAM_HTTP2 (stream); gsize data_needed = TEST_SIZE; guint8 *memory_chunk = g_new (guint8, CHUNK_SIZE); @@ -58,15 +57,13 @@ do_large_data_test (void) g_free (trash_buffer); g_free (memory_chunk); - g_object_unref (parent_stream); g_object_unref (stream); } static void do_multiple_chunk_test (void) { - GInputStream *parent_stream = g_memory_input_stream_new (); - GInputStream *stream = soup_body_input_stream_http2_new (G_POLLABLE_INPUT_STREAM (parent_stream)); + GInputStream *stream = soup_body_input_stream_http2_new (); SoupBodyInputStreamHttp2 *mem_stream = SOUP_BODY_INPUT_STREAM_HTTP2 (stream); const char * const chunks[] = { "1234", "5678", "9012", "hell", "owor", "ld..", @@ -85,7 +82,6 @@ do_multiple_chunk_test (void) g_assert_cmpstr (buffer, ==, chunks[i]); } - g_object_unref (parent_stream); g_object_unref (stream); } @@ -104,8 +100,7 @@ on_skip_ready (GInputStream *stream, GAsyncResult *res, GMainLoop *loop) static void do_skip_async_test (void) { - GInputStream *parent_stream = g_memory_input_stream_new (); - GInputStream *stream = soup_body_input_stream_http2_new (G_POLLABLE_INPUT_STREAM (parent_stream)); + GInputStream *stream = soup_body_input_stream_http2_new (); SoupBodyInputStreamHttp2 *bistream = SOUP_BODY_INPUT_STREAM_HTTP2 (stream); GMainLoop *loop = g_main_loop_new (NULL, FALSE); @@ -114,7 +109,6 @@ do_skip_async_test (void) g_input_stream_skip_async (stream, 2, G_PRIORITY_DEFAULT, NULL, (GAsyncReadyCallback)on_skip_ready, loop); g_main_loop_run (loop); - g_object_unref (parent_stream); g_object_unref (stream); g_main_loop_unref (loop); } |