]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-http: If connect to peer failed, don't recreate a new connection to handle pendin...
authorTimo Sirainen <tss@iki.fi>
Sat, 8 Jun 2013 23:08:24 +0000 (02:08 +0300)
committerTimo Sirainen <tss@iki.fi>
Sat, 8 Jun 2013 23:08:24 +0000 (02:08 +0300)
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

index 12618d03c044ce2fb54435f88b3b8c65c4caa913..9eb7dc379fc6a7e39f3e5b75608d625d3f89470a 100644 (file)
@@ -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);