summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergio Villar Senin <svillar@igalia.com>2013-03-04 11:26:17 +0100
committerSergio Villar Senin <svillar@igalia.com>2013-03-04 15:36:13 +0100
commit6c24fd0e6d3d6a1b18829e72e2508ad6fcf6f9e7 (patch)
treee185e3da8500441374c2bfca4a683f5a3ddeae75
parent5057f867f1e58fff45383f4a07ec1b6df3475342 (diff)
downloadlibsoup-6c24fd0e6d3d6a1b18829e72e2508ad6fcf6f9e7.tar.gz
libsoup-6c24fd0e6d3d6a1b18829e72e2508ad6fcf6f9e7.tar.bz2
libsoup-6c24fd0e6d3d6a1b18829e72e2508ad6fcf6f9e7.zip
soup-message-queue: hold a reference to the async context
This will ensure that the GMainContext is not freed at least until we get rid of the queue item. This was causing crashes when synchronously retrieving resources in WebKit as it uses a different GMainContext for each of those synchronous requests. https://bugzilla.gnome.org/show_bug.cgi?id=694920
-rw-r--r--libsoup/soup-message-queue.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/libsoup/soup-message-queue.c b/libsoup/soup-message-queue.c
index c7661d8c..8b1ebaf9 100644
--- a/libsoup/soup-message-queue.c
+++ b/libsoup/soup-message-queue.c
@@ -82,6 +82,8 @@ soup_message_queue_append (SoupMessageQueue *queue, SoupMessage *msg,
item = g_slice_new0 (SoupMessageQueueItem);
item->session = g_object_ref (queue->session);
item->async_context = soup_session_get_async_context (item->session);
+ if (item->async_context)
+ g_main_context_ref (item->async_context);
item->queue = queue;
item->msg = g_object_ref (msg);
item->callback = callback;
@@ -163,6 +165,7 @@ soup_message_queue_item_unref (SoupMessageQueueItem *item)
g_object_unref (item->msg);
g_object_unref (item->cancellable);
g_clear_object (&item->task);
+ g_clear_pointer (&item->async_context, g_main_context_unref);
if (item->io_source) {
g_source_destroy (item->io_source);
g_source_unref (item->io_source);