From: Dan Winship Date: Wed, 30 Nov 2011 17:30:26 +0000 (+0100) Subject: misc-test: fix a bug X-Git-Tag: LIBSOUP_2_37_3~8 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8477cbf40e28260d8101637eb7319deaec0af853;p=platform%2Fupstream%2Flibsoup.git misc-test: fix a bug misc-test would crash if it ran long enough (due to either stopping in gdb or just adding enough new tests to the end) because of a bug in the max_conns_test cleanup code. --- diff --git a/tests/misc-test.c b/tests/misc-test.c index 495c33f..b1bc2e7 100644 --- a/tests/misc-test.c +++ b/tests/misc-test.c @@ -820,6 +820,7 @@ do_persistent_connection_timeout_test (void) static GMainLoop *max_conns_loop; static int msgs_done; +static guint quit_loop_timeout; #define MAX_CONNS 2 #define TEST_CONNS (MAX_CONNS * 2) @@ -833,6 +834,7 @@ idle_start_server (gpointer data) static gboolean quit_loop (gpointer data) { + quit_loop_timeout = 0; g_main_loop_quit (max_conns_loop); return FALSE; } @@ -841,8 +843,11 @@ static void max_conns_request_started (SoupSession *session, SoupMessage *msg, SoupSocket *socket, gpointer user_data) { - if (++msgs_done == MAX_CONNS) - g_timeout_add (100, quit_loop, NULL); + if (++msgs_done == MAX_CONNS) { + if (quit_loop_timeout) + g_source_remove (quit_loop_timeout); + quit_loop_timeout = g_timeout_add (100, quit_loop, NULL); + } } static void @@ -857,7 +862,6 @@ do_max_conns_test_for_session (SoupSession *session) { SoupMessage *msgs[TEST_CONNS]; int i; - guint timeout_id; max_conns_loop = g_main_loop_new (NULL, TRUE); @@ -883,7 +887,7 @@ do_max_conns_test_for_session (SoupSession *session) msgs_done = 0; g_idle_add (idle_start_server, NULL); - timeout_id = g_timeout_add (1000, quit_loop, NULL); + quit_loop_timeout = g_timeout_add (1000, quit_loop, NULL); g_main_loop_run (max_conns_loop); for (i = 0; i < TEST_CONNS; i++) { @@ -902,10 +906,11 @@ do_max_conns_test_for_session (SoupSession *session) for (i = 0; i < TEST_CONNS; i++) soup_session_cancel_message (session, msgs[i], SOUP_STATUS_CANCELLED); g_main_loop_run (max_conns_loop); - g_source_remove (timeout_id); } g_main_loop_unref (max_conns_loop); + if (quit_loop_timeout) + g_source_remove (quit_loop_timeout); for (i = 0; i < TEST_CONNS; i++) g_object_unref (msgs[i]);