summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDan Winship <danw@gnome.org>2012-05-15 12:20:19 -0400
committerDan Winship <danw@gnome.org>2012-05-15 12:23:32 -0400
commitdba687f01cfe5aad36c3df1b830b1e1d6ab4592d (patch)
tree371af8e3ca744accb488b4234e366e2e8a019607 /tests
parentdbc41f65f80336052f57a2e3cfb48163a2a6185a (diff)
downloadlibsoup-dba687f01cfe5aad36c3df1b830b1e1d6ab4592d.tar.gz
libsoup-dba687f01cfe5aad36c3df1b830b1e1d6ab4592d.tar.bz2
libsoup-dba687f01cfe5aad36c3df1b830b1e1d6ab4592d.zip
soup-message-io: keep cancellable alive for duration of io_run_until
io_run() passes io->cancellable to io_run_until(), but io may be destroyed (and cancellable unreffed) before io_run_until() returns, causing it to eventually call g_cancellable_is_cancelled() on garbage. Fix by reffing it around the io_run_until() call (though really this is just another example of "SoupMessageIOData needs to be refcounted".) Tweak misc-test to test this case. Fixes crasher in rygel test case. Based on a patch from Ray Strode. https://bugzilla.gnome.org/show_bug.cgi?id=676038
Diffstat (limited to 'tests')
-rw-r--r--tests/misc-test.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/tests/misc-test.c b/tests/misc-test.c
index 39d63d3f..a2b99370 100644
--- a/tests/misc-test.c
+++ b/tests/misc-test.c
@@ -857,11 +857,20 @@ cancel_message_thread (gpointer msg)
}
static void
+set_done (SoupSession *session, SoupMessage *msg, gpointer user_data)
+{
+ gboolean *done = user_data;
+
+ *done = TRUE;
+}
+
+static void
do_cancel_while_reading_test_for_session (SoupSession *session)
{
SoupMessage *msg;
GThread *thread = NULL;
SoupURI *uri;
+ gboolean done = FALSE;
uri = soup_uri_new_with_base (base_uri, "/slow");
msg = soup_message_new_from_uri ("GET", uri);
@@ -875,7 +884,14 @@ do_cancel_while_reading_test_for_session (SoupSession *session)
else
thread = g_thread_new ("cancel_message_thread", cancel_message_thread, msg);
- soup_session_send_message (session, msg);
+ /* We intentionally don't use soup_session_send_message() here,
+ * because it holds an extra ref on the SoupMessageQueueItem
+ * relative to soup_session_queue_message().
+ */
+ g_object_ref (msg);
+ soup_session_queue_message (session, msg, set_done, &done);
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
if (msg->status_code != SOUP_STATUS_CANCELLED) {
debug_printf (1, " FAILED: %d %s (expected Cancelled)\n",