From: Timo Sirainen Date: Sat, 8 Jun 2013 23:08:24 +0000 (+0300) Subject: lib-http: If connect to peer failed, don't recreate a new connection to handle pendin... X-Git-Tag: 2.2.3~41 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6ce13ae0860bbacc1b8b45cd330a0c5ae57d7873;p=thirdparty%2Fdovecot%2Fcore.git 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. --- 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);