From 3d0441b3f0c402447306f53789a47abdc573f8f3 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Sat, 22 Aug 2009 09:11:45 -0400 Subject: [PATCH] Avoid infinite loop trying to connect to host when the network is down. 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 | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/libsoup/soup-session.c b/libsoup/soup-session.c index bcfb816..c8c1b34 100644 --- a/libsoup/soup-session.c +++ b/libsoup/soup-session.c @@ -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); -- 2.7.4