summaryrefslogtreecommitdiff
path: root/tests/test-utils.c
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2008-09-30 15:43:17 +0000
committerDan Winship <danw@src.gnome.org>2008-09-30 15:43:17 +0000
commitdd40c1515f1687c614f2dc670aca49fad8ad2088 (patch)
treed655241a87d19acc345dcdba90c09172426c0227 /tests/test-utils.c
parent91c185ead4d7d5560887d7fa13aeecf9ed320998 (diff)
downloadlibsoup-dd40c1515f1687c614f2dc670aca49fad8ad2088.tar.gz
libsoup-dd40c1515f1687c614f2dc670aca49fad8ad2088.tar.bz2
libsoup-dd40c1515f1687c614f2dc670aca49fad8ad2088.zip
store the GSource in priv, don't ref the session. Otherwise the session
* libsoup/soup-session-async.c (do_idle_run_queue): store the GSource in priv, don't ref the session. Otherwise the session won't get destroyed if you abort it and then don't return to its main loop. (addendum to #498509, Arnout Vandecappelle) (finalize): Destroy the idle_run_queue source when finalizing. (run_queue, got_connection): Ref the session when calling soup_connection_connect_async(), and do a do_idle_run_queue()+unref in got_connection, to ensure correct handling regardless of what the application does with its own ref on the session. (final_finished): Likewise, ref/do_idle_run_queue/unref rather than calling run_queue directly and playing with weak pointers. * libsoup/soup-session.c (connect_result): ref the session around the cancel-if-error loop Fixes #533473, crash in seahorse when connecting to a non-responsive key server. * tests/misc-test.c (do_callback_unref_test): Add a test for the bug in #533473. * tests/test-utils.c (soup_test_session_abort_unref): abort and unref a SoupSession, and consider it an error if the session still exists afterward. Suggested by Arnout Vandecappelle. (test_server_shutdown): Likewise, consider it an error if the server is leaked. * tests/*.c: Use soup_test_session_abort_unref(). svn path=/trunk/; revision=1168
Diffstat (limited to 'tests/test-utils.c')
-rw-r--r--tests/test-utils.c43
1 files changed, 33 insertions, 10 deletions
diff --git a/tests/test-utils.c b/tests/test-utils.c
index f0f2860d..0bb4a89a 100644
--- a/tests/test-utils.c
+++ b/tests/test-utils.c
@@ -100,14 +100,6 @@ test_init (int argc, char **argv, GOptionEntry *entries)
void
test_cleanup (void)
{
- debug_printf (1, "\n");
- if (errors) {
- printf ("%s: %d error(s).%s\n",
- g_get_prgname (), errors,
- debug_level == 0 ? " Run with '-d' for details" : "");
- } else
- printf ("%s: OK\n", g_get_prgname ());
-
#ifdef HAVE_APACHE
if (apache_running)
apache_cleanup ();
@@ -119,6 +111,14 @@ test_cleanup (void)
g_object_unref (logger);
g_main_context_unref (g_main_context_default ());
+
+ debug_printf (1, "\n");
+ if (errors) {
+ printf ("%s: %d error(s).%s\n",
+ g_get_prgname (), errors,
+ debug_level == 0 ? " Run with '-d' for details" : "");
+ } else
+ printf ("%s: OK\n", g_get_prgname ());
}
void
@@ -225,6 +225,21 @@ soup_test_session_new (GType type, ...)
return session;
}
+void
+soup_test_session_abort_unref (SoupSession *session)
+{
+ g_object_add_weak_pointer (G_OBJECT (session), (gpointer *)&session);
+
+ soup_session_abort (session);
+ g_object_unref (session);
+
+ if (session) {
+ errors++;
+ debug_printf (1, "leaked SoupSession!\n");
+ g_object_remove_weak_pointer (G_OBJECT (session), (gpointer *)&session);
+ }
+}
+
static gpointer run_server_thread (gpointer user_data);
SoupServer *
@@ -271,6 +286,9 @@ idle_quit_server (gpointer server)
static void
test_server_shutdown (void)
{
+ g_object_add_weak_pointer (G_OBJECT (test_server),
+ (gpointer *)&test_server);
+
if (server_thread) {
soup_add_completion (soup_server_get_async_context (test_server),
idle_quit_server, test_server);
@@ -278,6 +296,11 @@ test_server_shutdown (void)
} else
soup_server_quit (test_server);
g_object_unref (test_server);
-}
-
+ if (test_server) {
+ errors++;
+ debug_printf (1, "leaked SoupServer!\n");
+ g_object_remove_weak_pointer (G_OBJECT (test_server),
+ (gpointer *)&test_server);
+ }
+}