[libsoup/cache] soup-session-async: move cache handling to run_queue
- From: Xan Lopez <xan src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [libsoup/cache] soup-session-async: move cache handling to run_queue
- Date: Tue, 4 Aug 2009 07:28:27 +0000 (UTC)
commit fffdc9a51b5d5ce517ed5793fbaa8b81b8dd838f
Author: Xan Lopez <xan gnome org>
Date: Tue Aug 4 10:18:14 2009 +0300
soup-session-async: move cache handling to run_queue
We were queueing an idle function queue_message before, but this can
fail in the following way: if run_queue is somehow called before the
scheduled idle runs, it will find the message you intended to reply to
from the cache in the queue, and will request it to the server anyway.
Now we reply directly when iterating the queue, and set the IOStatus
to RUNNING so that we don't reply more than once.
libsoup/soup-session-async.c | 13 +++++++------
1 files changed, 7 insertions(+), 6 deletions(-)
---
diff --git a/libsoup/soup-session-async.c b/libsoup/soup-session-async.c
index c57d303..483d947 100644
--- a/libsoup/soup-session-async.c
+++ b/libsoup/soup-session-async.c
@@ -298,6 +298,7 @@ run_queue (SoupSessionAsync *sa)
SoupMessageQueueItem *item;
SoupProxyURIResolver *proxy_resolver =
soup_session_get_proxy_resolver (session);
+ SoupCache * cache = soup_session_get_cache (session);
SoupMessage *msg;
SoupMessageIOStatus cur_io_status = SOUP_MESSAGE_IO_STATUS_CONNECTING;
SoupConnection *conn;
@@ -309,6 +310,12 @@ run_queue (SoupSessionAsync *sa)
item = soup_message_queue_next (queue, item)) {
msg = item->msg;
+ if (cache && soup_cache_has_response (cache, session, msg)) {
+ soup_message_set_io_status (msg, SOUP_MESSAGE_IO_STATUS_RUNNING);
+ soup_cache_send_response (cache, session, msg);
+ continue;
+ }
+
/* CONNECT messages are handled specially */
if (msg->method == SOUP_METHOD_CONNECT)
continue;
@@ -432,12 +439,6 @@ queue_message (SoupSession *session, SoupMessage *req,
g_signal_connect_after (req, "finished",
G_CALLBACK (final_finished), item);
- cache = soup_session_get_cache (session);
- if (cache && soup_cache_has_response (cache, session, req)) {
- g_idle_add ((GSourceFunc)had_cache, item);
- return;
- }
-
do_idle_run_queue (session);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]