diff options
author | Dan Winship <danw@gnome.org> | 2012-10-31 11:08:06 -0400 |
---|---|---|
committer | Dan Winship <danw@gnome.org> | 2012-10-31 11:09:42 -0400 |
commit | 04a0a7c674fcc8adc28da84eba1b79c4d9acb246 (patch) | |
tree | 0e9836460fa7d4e35ea93f2f274998264d11dd52 /tests | |
parent | c4ff1663520f2167d274ac04cad7a88e9ba5902c (diff) | |
download | libsoup-04a0a7c674fcc8adc28da84eba1b79c4d9acb246.tar.gz |
tests: fix some race conditions
A few tests were written such that they could fail/crash if the machine
was too slow. Fix.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/connection-test.c | 13 | ||||
-rw-r--r-- | tests/misc-test.c | 3 |
2 files changed, 12 insertions, 4 deletions
diff --git a/tests/connection-test.c b/tests/connection-test.c index b9dce7f5..ef21ec97 100644 --- a/tests/connection-test.c +++ b/tests/connection-test.c @@ -541,8 +541,6 @@ do_max_conns_test (void) soup_test_session_abort_unref (session); } -GMainLoop *loop; - static void np_request_started (SoupSession *session, SoupMessage *msg, SoupSocket *socket, gpointer user_data) @@ -562,6 +560,13 @@ np_request_unqueued (SoupSession *session, SoupMessage *msg, debug_printf (1, " socket is still connected\n"); errors++; } +} + +static void +np_request_finished (SoupSession *session, SoupMessage *msg, + gpointer user_data) +{ + GMainLoop *loop = user_data; g_main_loop_quit (loop); } @@ -571,6 +576,7 @@ do_non_persistent_test_for_session (SoupSession *session) { SoupMessage *msg; SoupSocket *socket = NULL; + GMainLoop *loop; loop = g_main_loop_new (NULL, FALSE); @@ -584,7 +590,8 @@ do_non_persistent_test_for_session (SoupSession *session) msg = soup_message_new_from_uri ("GET", base_uri); soup_message_headers_append (msg->request_headers, "Connection", "close"); g_object_ref (msg); - soup_session_queue_message (session, msg, NULL, NULL); + soup_session_queue_message (session, msg, + np_request_finished, loop); g_main_loop_run (loop); g_main_loop_unref (loop); diff --git a/tests/misc-test.c b/tests/misc-test.c index a71d4aae..19e9ba09 100644 --- a/tests/misc-test.c +++ b/tests/misc-test.c @@ -928,6 +928,7 @@ cancel_request_thread (gpointer cancellable) { g_usleep (100000); /* .1s */ g_cancellable_cancel (cancellable); + g_object_unref (cancellable); return NULL; } @@ -951,7 +952,7 @@ do_cancel_while_reading_req_test_for_session (SoupRequester *requester) } else { GThread *thread; - thread = g_thread_new ("cancel_request_thread", cancel_request_thread, cancellable); + thread = g_thread_new ("cancel_request_thread", cancel_request_thread, g_object_ref (cancellable)); soup_test_request_send (req, cancellable, &error); g_thread_unref (thread); } |