From 6ce13ae0860bbacc1b8b45cd330a0c5ae57d7873 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Sun, 9 Jun 2013 02:08:24 +0300 Subject: [PATCH] lib-http: If connect to peer failed, don't recreate a new connection to handle pending requests. The new connection would very likely fail as well. Another peer for the host should pick up the requests. --- src/lib-http/http-client-peer.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/lib-http/http-client-peer.c b/src/lib-http/http-client-peer.c index 12618d03c0..9eb7dc379f 100644 --- a/src/lib-http/http-client-peer.c +++ b/src/lib-http/http-client-peer.c @@ -277,12 +277,12 @@ void http_client_peer_connection_failure(struct http_client_peer *peer, http_client_peer_debug(peer, "Failed to make connection"); + peer->last_connect_failed = TRUE; if (array_count(&peer->conns) > 1) { /* if there are other connections attempting to connect, wait for them before failing the requests. remember that we had trouble with connecting so in future we don't try to create more than one connection until connects work again. */ - peer->last_connect_failed = TRUE; } else { /* this was the only/last connection and connecting to it failed. a second connect will probably also fail, so just @@ -306,8 +306,11 @@ void http_client_peer_connection_lost(struct http_client_peer *peer) http_client_peer_debug(peer, "Lost a connection (%d connections left)", array_count(&peer->conns)); - /* if there are pending requests, create a new connection for them. */ - http_client_peer_handle_requests(peer); + if (!peer->last_connect_failed) { + /* if there are pending requests, create a new + connection for them. */ + http_client_peer_handle_requests(peer); + } if (array_count(&peer->conns) == 0 && http_client_peer_requests_pending(peer, &num_urgent) == 0) http_client_peer_free(&peer); -- 2.47.3