diff -ru libsoup.orig/soup-session-async.c libsoup/soup-session-async.c
--- libsoup.orig/soup-session-async.c	2009-07-06 11:09:45.721176043 +0200
+++ libsoup/soup-session-async.c	2009-07-06 11:13:51.561176868 +0200
@@ -220,14 +220,16 @@
 	}
 
 	if (!SOUP_STATUS_IS_SUCCESSFUL (msg->status_code)) {
-		soup_session_connection_failed (data->session, data->conn,
-						msg->status_code);
+		soup_session_connection_failed_for_tunnel_connect (data->session,
+								   data->conn, msg,
+								   msg->status_code);
 		goto done;
 	}
 
 	if (!soup_connection_start_ssl (data->conn)) {
-		soup_session_connection_failed (data->session, data->conn,
-						SOUP_STATUS_SSL_FAILED);
+		soup_session_connection_failed_for_tunnel_connect (data->session,
+								   data->conn, msg,
+								   SOUP_STATUS_SSL_FAILED);
 		goto done;
 	}
 
diff -ru libsoup.orig/soup-session.c libsoup/soup-session.c
--- libsoup.orig/soup-session.c	2009-07-06 11:09:45.721176043 +0200
+++ libsoup/soup-session.c	2009-07-06 11:11:09.946178945 +0200
@@ -1022,6 +1022,39 @@
 	g_object_unref (session);
 }
 
+/**
+ * connection_failed remplacement when it happends for tunnel_connect.
+ * Like the connection is not referenced in the conns, this function is
+ * needed.
+ */
+void
+soup_session_connection_failed_for_tunnel_connect (SoupSession *session,
+						   SoupConnection *conn,
+						   SoupMessage *req,
+						   guint status)
+{
+	SoupSessionPrivate *priv = SOUP_SESSION_GET_PRIVATE (session);
+	SoupMessageQueueItem *item;
+	SoupMessage *msg;
+	SoupSessionHost *host;
+
+	g_mutex_lock (priv->host_lock);
+	host = get_host_for_message (session, req);
+	g_mutex_unlock (priv->host_lock);
+
+	/* Assume that there's something wrong with the host, and
+	 * 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)
+			soup_session_cancel_message (session, msg, status);
+	}
+	g_object_unref (session);
+}
+
 static void
 tunnel_connected (SoupSession *session, SoupMessage *msg, gpointer user_data)
 {
diff -ru libsoup.orig/soup-session-private.h libsoup/soup-session-private.h
--- libsoup.orig/soup-session-private.h	2009-07-06 11:09:45.729155829 +0200
+++ libsoup/soup-session-private.h	2009-07-06 11:11:57.474154428 +0200
@@ -25,6 +25,11 @@
 void                  soup_session_connection_failed    (SoupSession          *session,
 							 SoupConnection       *conn,
 							 guint                 status);
+void                  soup_session_connection_failed_for_tunnel_connect
+							(SoupSession *session,
+							 SoupConnection *conn,
+							 SoupMessage *req,
+							 guint status);
 
 SoupProxyURIResolver *soup_session_get_proxy_resolver   (SoupSession          *session);
 
