Avoid infinite loop trying to connect to host when the network is down.
authorDan Winship <danw@gnome.org>
Sat, 22 Aug 2009 13:11:45 +0000 (09:11 -0400)
committerDan Winship <danw@gnome.org>
Sat, 22 Aug 2009 13:32:28 +0000 (09:32 -0400)
If a connection attempt to a host fails, fail all of the messages
queued for that host.

Previously we would leave them in the queue if there was already an
existing connection to the host (hoping that we'd be able to reuse
that connection for the other messages later), but this meant that if
there was a single connection to a host open, with a message running
on it, and at least one additional queued message to the same host,
and then the network went down, libsoup would get stuck in a loop
repeatedly trying and failing to open a second connection (with the
first connection never getting a chance to time out).

http://bugzilla.gnome.org/show_bug.cgi?id=592492

libsoup/soup-session.c

index bcfb816..c8c1b34 100644 (file)
@@ -1030,23 +1030,14 @@ soup_session_connection_failed (SoupSession *session,
 
        connection_disconnected (conn, session);
 
-       if (host->connections) {
-               /* Something went wrong this time, but we have at
-                * least one open connection to this host. So just
-                * leave the message in the queue so it can use that
-                * connection once it's free.
-                */
-               return;
-       }
-
-       /* Assume that there's something wrong with the host, and
-        * cancel any other messages waiting for a connection to it,
+       /* Cancel any other messages waiting for a connection to it,
         * since they're out of luck.
         */
        g_object_ref (session);
        for (item = soup_message_queue_first (priv->queue); item; item = soup_message_queue_next (priv->queue, item)) {
                msg = item->msg;
-               if (get_host_for_message (session, msg) == host)
+               if (SOUP_MESSAGE_IS_STARTING (msg) &&
+                   get_host_for_message (session, msg) == host)
                        soup_session_cancel_message (session, msg, status);
        }
        g_object_unref (session);