[libsoup] soup_session_queue_message: simplify the msg refcounting internally
- From: Dan Winship <danw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsoup] soup_session_queue_message: simplify the msg refcounting internally
- Date: Mon, 16 Jul 2012 16:13:04 +0000 (UTC)
commit 0091d027eb6b5c0af093995f5e95f49b1daddf7b
Author: Dan Winship <danw gnome org>
Date: Sun May 27 11:49:26 2012 -0400
soup_session_queue_message: simplify the msg refcounting internally
libsoup/soup-session-async.c | 7 -------
libsoup/soup-session-sync.c | 2 --
libsoup/soup-session.c | 4 ++++
3 files changed, 4 insertions(+), 9 deletions(-)
---
diff --git a/libsoup/soup-session-async.c b/libsoup/soup-session-async.c
index 5a45b23..4690055 100644
--- a/libsoup/soup-session-async.c
+++ b/libsoup/soup-session-async.c
@@ -305,7 +305,6 @@ process_queue_item (SoupMessageQueueItem *item,
item->callback (session, item->msg, item->callback_data);
else if (item->new_api)
send_request_finished (session, item);
- g_object_unref (item->msg);
do_idle_run_queue (session);
g_object_unref (session);
return;
@@ -412,9 +411,6 @@ soup_session_async_send_message (SoupSession *session, SoupMessage *req)
GMainContext *async_context =
soup_session_get_async_context (session);
- /* Balance out the unref that queuing will eventually do */
- g_object_ref (req);
-
soup_session_async_queue_message (session, req, NULL, NULL);
item = soup_message_queue_lookup (soup_session_get_queue (session), req);
@@ -706,9 +702,6 @@ soup_session_send_request_async (SoupSession *session,
NULL);
g_return_if_fail (use_thread_context);
- /* Balance out the unref that queuing will eventually do */
- g_object_ref (msg);
-
soup_session_async_queue_message (session, msg, NULL, NULL);
item = soup_message_queue_lookup (soup_session_get_queue (session), msg);
diff --git a/libsoup/soup-session-sync.c b/libsoup/soup-session-sync.c
index b86a6ca..96ab916 100644
--- a/libsoup/soup-session-sync.c
+++ b/libsoup/soup-session-sync.c
@@ -298,7 +298,6 @@ queue_message_callback (gpointer data)
item->callback (item->session, item->msg, item->callback_data);
g_object_unref (item->session);
- g_object_unref (item->msg);
soup_message_queue_item_unref (item);
return FALSE;
}
@@ -314,7 +313,6 @@ queue_message_thread (gpointer data)
queue_message_callback, item);
} else {
g_object_unref (item->session);
- g_object_unref (item->msg);
soup_message_queue_item_unref (item);
}
diff --git a/libsoup/soup-session.c b/libsoup/soup-session.c
index 7624afb..94d18a6 100644
--- a/libsoup/soup-session.c
+++ b/libsoup/soup-session.c
@@ -1405,6 +1405,10 @@ soup_session_queue_message (SoupSession *session, SoupMessage *msg,
SOUP_SESSION_GET_CLASS (session)->queue_message (session, msg,
callback, user_data);
+ /* The SoupMessageQueueItem will hold a ref on @msg until it is
+ * finished, so we can drop the ref adopted from the caller now.
+ */
+ g_object_unref (msg);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]