summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libsoup/soup-session.c17
-rw-r--r--tests/cache-test.c7
-rw-r--r--tests/connection-test.c4
-rw-r--r--tests/http2-test.c48
-rw-r--r--tests/misc-test.c22
-rw-r--r--tests/multipart-test.c2
-rw-r--r--tests/multithread-test.c3
-rw-r--r--tests/test-utils.c10
8 files changed, 14 insertions, 99 deletions
diff --git a/libsoup/soup-session.c b/libsoup/soup-session.c
index cbc00b9d..4d4c8654 100644
--- a/libsoup/soup-session.c
+++ b/libsoup/soup-session.c
@@ -1471,9 +1471,7 @@ message_completed (SoupMessage *msg, SoupMessageIOCompletion completion, gpointe
if (item->state != SOUP_MESSAGE_RESTARTING) {
item->state = SOUP_MESSAGE_FINISHING;
-
- if (!item->async)
- soup_session_process_queue_item (item->session, item, TRUE);
+ soup_session_process_queue_item (item->session, item, !item->async);
}
}
@@ -3643,8 +3641,6 @@ soup_session_get_supported_websocket_extensions_for_message (SoupSession *sessio
return soup_websocket_extension_manager_get_supported_extensions (SOUP_WEBSOCKET_EXTENSION_MANAGER (extension_manager));
}
-static void websocket_connect_async_stop (SoupMessage *msg, gpointer user_data);
-
static void
websocket_connect_async_complete (SoupMessage *msg, gpointer user_data)
{
@@ -3677,11 +3673,10 @@ websocket_connect_async_stop (SoupMessage *msg, gpointer user_data)
GList *accepted_extensions = NULL;
GError *error = NULL;
- g_signal_handlers_disconnect_matched (msg, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, task);
-
supported_extensions = soup_session_get_supported_websocket_extensions_for_message (session, msg);
if (soup_websocket_client_verify_handshake (item->msg, supported_extensions, &accepted_extensions, &error)) {
+ g_signal_handlers_disconnect_matched (msg, G_SIGNAL_MATCH_DATA,
+ 0, 0, NULL, NULL, task);
stream = soup_session_steal_connection (item->session, item->msg);
client = soup_websocket_connection_new (stream,
soup_message_get_uri (item->msg),
@@ -3696,9 +3691,9 @@ websocket_connect_async_stop (SoupMessage *msg, gpointer user_data)
return;
}
- soup_message_io_finished (item->msg);
- g_task_return_error (task, error);
- g_object_unref (task);
+ g_assert (!item->error);
+ item->error = error;
+ soup_message_io_finished (item->msg);
}
/**
diff --git a/tests/cache-test.c b/tests/cache-test.c
index e842005f..b58bb1d6 100644
--- a/tests/cache-test.c
+++ b/tests/cache-test.c
@@ -597,9 +597,6 @@ do_refcounting_test (gconstpointer data)
g_object_unref (cache);
g_free (cache_dir);
-
- while (g_main_context_pending (NULL))
- g_main_context_iteration (NULL, FALSE);
soup_test_session_abort_unref (session);
}
@@ -942,10 +939,6 @@ task_async_function (GTask *task,
g_object_unref (msg);
- /* Continue iterating to ensure the item is unqueued and the connection released */
- while (g_main_context_pending (context))
- g_main_context_iteration (context, TRUE);
-
/* Cache writes are G_PRIORITY_LOW, so they won't have happened yet */
soup_cache_flush ((SoupCache *)soup_session_get_feature (request->session, SOUP_TYPE_CACHE));
diff --git a/tests/connection-test.c b/tests/connection-test.c
index 18b75f31..307a695f 100644
--- a/tests/connection-test.c
+++ b/tests/connection-test.c
@@ -1690,10 +1690,6 @@ do_connection_http_1_1_required_test (void)
g_assert_nonnull (body);
g_bytes_unref (body);
g_object_unref (msg);
-
- while (g_main_context_pending (NULL))
- g_main_context_iteration (NULL, FALSE);
-
soup_test_session_abort_unref (session);
}
diff --git a/tests/http2-test.c b/tests/http2-test.c
index 19cee8e1..57f85594 100644
--- a/tests/http2-test.c
+++ b/tests/http2-test.c
@@ -194,9 +194,6 @@ do_multi_message_async_test (Test *test, gconstpointer data)
g_assert_cmpstr (g_bytes_get_data (response1, NULL), ==, "body%201");
g_assert_cmpstr (g_bytes_get_data (response2, NULL), ==, "body%202");
- while (g_main_context_pending (async_context))
- g_main_context_iteration (async_context, FALSE);
-
g_bytes_unref (response1);
g_bytes_unref (response2);
g_object_unref (msg1);
@@ -316,9 +313,6 @@ do_one_cancel_after_send_request_test (SoupSession *session,
g_bytes_unref (body);
}
- while (g_main_context_pending (NULL))
- g_main_context_iteration (NULL, FALSE);
-
g_object_unref (cancellable);
g_object_unref (ostream);
g_object_unref (istream);
@@ -414,9 +408,6 @@ do_post_async_test (Test *test, gconstpointer data)
g_assert_cmpstr (g_bytes_get_data (response, NULL), ==, "body 1");
- while (g_main_context_pending (async_context))
- g_main_context_iteration (async_context, FALSE);
-
g_bytes_unref (response);
g_bytes_unref (bytes);
g_main_context_unref (async_context);
@@ -451,9 +442,6 @@ do_post_large_async_test (Test *test, gconstpointer data)
g_assert_true (g_bytes_equal (bytes, response));
- while (g_main_context_pending (async_context))
- g_main_context_iteration (async_context, FALSE);
-
g_bytes_unref (response);
g_bytes_unref (bytes);
g_main_context_unref (async_context);
@@ -489,9 +477,6 @@ do_post_blocked_async_test (Test *test, gconstpointer data)
g_assert_cmpstr (g_bytes_get_data (response, NULL), ==, "Part 1 - Part 2");
- while (g_main_context_pending (async_context))
- g_main_context_iteration (async_context, FALSE);
-
g_bytes_unref (response);
g_object_unref (in_stream);
g_main_context_unref (async_context);
@@ -522,9 +507,6 @@ do_post_file_async_test (Test *test, gconstpointer data)
g_assert_true (g_str_has_prefix (g_bytes_get_data (response, NULL), "-----BEGIN CERTIFICATE-----"));
- while (g_main_context_pending (async_context))
- g_main_context_iteration (async_context, FALSE);
-
g_bytes_unref (response);
g_object_unref (in_stream);
g_object_unref (in_file);
@@ -584,25 +566,23 @@ on_send_ready (GObject *source, GAsyncResult *res, gpointer user_data)
GInputStream *stream;
stream = soup_session_send_finish (sess, res, &error);
-
g_assert_no_error (error);
g_assert_nonnull (stream);
- GBytes *result = read_stream_to_bytes_sync (stream);
- g_object_unref (stream);
- g_assert_nonnull (result);
- g_assert_cmpstr (g_bytes_get_data (result, NULL), ==, "Hello world");
- g_bytes_unref (result);
-
g_assert_nonnull (msg);
g_assert_cmpuint (soup_message_get_http_version (msg), ==, SOUP_HTTP_2_0);
conn = soup_message_get_connection (msg);
-
if (last_connection)
- g_assert (last_connection == conn);
+ g_assert_true (last_connection == conn);
else
last_connection = conn;
-
+
+ GBytes *result = read_stream_to_bytes_sync (stream);
+ g_object_unref (stream);
+ g_assert_nonnull (result);
+ g_assert_cmpstr (g_bytes_get_data (result, NULL), ==, "Hello world");
+ g_bytes_unref (result);
+
g_test_message ("Conn (%u) = %p", *complete_count, conn);
*complete_count += 1;
@@ -635,9 +615,6 @@ do_connections_test (Test *test, gconstpointer data)
g_main_context_iteration (async_context, TRUE);
}
- while (g_main_context_pending (async_context))
- g_main_context_iteration (async_context, FALSE);
-
/* After no messages reference the connection it should be IDLE and reusable */
g_assert_cmpuint (soup_connection_get_state (last_connection), ==, SOUP_CONNECTION_IDLE);
SoupMessage *msg = soup_message_new_from_uri (SOUP_METHOD_GET, uri);
@@ -647,9 +624,6 @@ do_connections_test (Test *test, gconstpointer data)
while (complete_count != N_TESTS + 1)
g_main_context_iteration (async_context, TRUE);
- while (g_main_context_pending (async_context))
- g_main_context_iteration (async_context, FALSE);
-
g_uri_unref (uri);
g_main_context_unref (async_context);
}
@@ -1124,9 +1098,6 @@ do_sniffer_async_test (Test *test, gconstpointer data)
do_one_sniffer_test (test->session, "/large", (LARGE_N_CHARS * LARGE_CHARS_REPEAT) + 1, should_content_sniff, async_context);
do_one_sniffer_test (test->session, "/no-content", 0, should_content_sniff, async_context);
- while (g_main_context_pending (async_context))
- g_main_context_iteration (async_context, FALSE);
-
g_main_context_unref (async_context);
}
@@ -1160,9 +1131,6 @@ do_timeout_test (Test *test, gconstpointer data)
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_TIMED_OUT);
g_object_unref (msg);
g_uri_unref (uri);
-
- while (g_main_context_pending (NULL))
- g_main_context_iteration (NULL, FALSE);
}
static void
diff --git a/tests/misc-test.c b/tests/misc-test.c
index 85b37598..045161d8 100644
--- a/tests/misc-test.c
+++ b/tests/misc-test.c
@@ -378,9 +378,6 @@ do_msg_reuse_test (void)
g_clear_error (&error);
g_object_unref (stream);
- while (g_main_context_pending (NULL))
- g_main_context_iteration (NULL, FALSE);
-
ensure_no_signal_handlers (msg, signal_ids, n_signal_ids);
soup_test_session_abort_unref (session);
@@ -454,7 +451,6 @@ do_early_abort_test (void)
(GAsyncReadyCallback)ea_msg_completed_one,
loop);
g_object_unref (msg);
- g_main_context_iteration (context, FALSE);
soup_session_abort (session);
while (g_main_context_pending (context))
@@ -474,10 +470,6 @@ do_early_abort_test (void)
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_CANCELLED);
g_clear_error (&error);
g_object_unref (msg);
-
- while (g_main_context_pending (context))
- g_main_context_iteration (context, FALSE);
-
soup_test_session_abort_unref (session);
g_test_bug ("668098");
@@ -495,10 +487,6 @@ do_early_abort_test (void)
g_clear_error (&error);
g_object_unref (cancellable);
g_object_unref (msg);
-
- while (g_main_context_pending (context))
- g_main_context_iteration (context, FALSE);
-
soup_test_session_abort_unref (session);
}
@@ -698,9 +686,6 @@ do_one_cancel_after_send_request_test (SoupSession *session,
g_bytes_unref (body);
}
- while (g_main_context_pending (NULL))
- g_main_context_iteration (NULL, FALSE);
-
g_object_unref (cancellable);
g_object_unref (ostream);
g_object_unref (istream);
@@ -991,9 +976,6 @@ do_new_request_on_conflict_test (void)
g_object_unref (msg);
g_object_unref (data.cancellable);
- while (g_main_context_pending (NULL))
- g_main_context_iteration (NULL, FALSE);
-
data.cancellable = g_cancellable_new ();
data.connections[0] = data.connections[1] = 0;
data.done = FALSE;
@@ -1014,10 +996,6 @@ do_new_request_on_conflict_test (void)
g_object_unref (msg);
g_object_unref (data.cancellable);
-
- while (g_main_context_pending (NULL))
- g_main_context_iteration (NULL, FALSE);
-
g_uri_unref (uri);
g_bytes_unref (data.body);
soup_test_session_abort_unref (data.session);
diff --git a/tests/multipart-test.c b/tests/multipart-test.c
index ba61e199..8c80265e 100644
--- a/tests/multipart-test.c
+++ b/tests/multipart-test.c
@@ -452,8 +452,6 @@ test_multipart (gconstpointer data)
soup_session_send_async (session, msg, 0, NULL, no_multipart_handling_cb, NULL);
g_main_loop_run (loop);
- while (g_main_context_pending (NULL))
- g_main_context_iteration (NULL, FALSE);
content_type = soup_message_headers_get_content_type (soup_message_get_response_headers (msg), &params);
diff --git a/tests/multithread-test.c b/tests/multithread-test.c
index c0378531..7ef67574 100644
--- a/tests/multithread-test.c
+++ b/tests/multithread-test.c
@@ -365,9 +365,6 @@ do_multithread_connections_test (Test *test,
body = soup_test_session_async_send (test->session, msg, NULL, NULL);
g_bytes_unref (body);
- while (g_main_context_pending (NULL))
- g_main_context_iteration (NULL, FALSE);
-
g_assert_nonnull (conn);
g_assert_cmpuint (soup_connection_get_state (conn), ==, SOUP_CONNECTION_IDLE);
diff --git a/tests/test-utils.c b/tests/test-utils.c
index 3f599c45..d29d1175 100644
--- a/tests/test-utils.c
+++ b/tests/test-utils.c
@@ -727,12 +727,8 @@ async_as_sync_callback (GObject *object,
gpointer user_data)
{
AsyncAsSyncData *data = user_data;
- GMainContext *context;
data->result = g_object_ref (result);
- context = g_main_loop_get_context (data->loop);
- while (g_main_context_pending (context))
- g_main_context_iteration (context, FALSE);
g_main_loop_quit (data->loop);
}
@@ -772,16 +768,10 @@ soup_test_request_send (SoupSession *session,
stream = soup_session_send_finish (session, data.result, error);
if (flags & SOUP_TEST_REQUEST_CANCEL_AFTER_SEND_FINISH) {
- GMainContext *context;
-
if (flags & SOUP_TEST_REQUEST_CANCEL_BY_SESSION)
soup_session_cancel_message (session, msg);
else
g_cancellable_cancel (cancellable);
-
- context = g_main_loop_get_context (data.loop);
- while (g_main_context_pending (context))
- g_main_context_iteration (context, FALSE);
}
g_main_loop_unref (data.loop);