soup-session: don't mark CONNECTING connections IDLE on cancel
authorDan Winship <danw@gnome.org>
Thu, 1 Mar 2012 16:34:37 +0000 (11:34 -0500)
committerDan Winship <danw@gnome.org>
Thu, 1 Mar 2012 16:34:37 +0000 (11:34 -0500)
When finishing up a queue item, SoupSession was always marking its
connection IDLE, even if it had previously been CONNECTING. This
created a race condition where if lots of pending connections were
cancelled at once, some of them might see connections labelled IDLE
that didn't actually have a SoupSocket (before those connections got
asynchronously cleaned up). Fix this by only marking connections IDLE
if they had previously been IN_USE.

https://bugzilla.gnome.org/show_bug.cgi?id=667245

libsoup/soup-session.c

index f5f7f72..22a02fd 100644 (file)
@@ -1976,7 +1976,8 @@ soup_session_unqueue_item (SoupSession          *session,
        SoupSessionHost *host;
 
        if (item->conn) {
-               soup_connection_set_state (item->conn, SOUP_CONNECTION_IDLE);
+               if (soup_connection_get_state (item->conn) == SOUP_CONNECTION_IN_USE)
+                       soup_connection_set_state (item->conn, SOUP_CONNECTION_IDLE);
                soup_message_queue_item_set_connection (item, NULL);
        }