]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-http: client: connection: Unlist the connection as pending immediately in http_cl...
authorStephan Bosch <stephan.bosch@dovecot.fi>
Thu, 6 Sep 2018 01:23:26 +0000 (03:23 +0200)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Fri, 7 Sep 2018 06:18:56 +0000 (09:18 +0300)
src/lib-http/http-client-connection.c
src/lib-http/http-client-peer.c

index c13430af4a4a14b2e9d1d5c88549f7e33fb1b29d..abb7bb922339ee50c607d21cf2c6c482db1f431b 100644 (file)
@@ -71,6 +71,7 @@ http_client_connection_failure(struct http_client_connection *conn,
        struct http_client_peer *peer = conn->peer;
 
        conn->connect_failed = TRUE;
+       http_client_connection_unlist_pending(conn);
        http_client_peer_connection_failure(peer, reason);
 }
 
index 180a9006b188cdbbbb87a774430a87ef55bcd582..afa71e94ecb0cf2f0ed831876743f92e8c49fe2f 100644 (file)
@@ -246,20 +246,14 @@ static void
 http_client_peer_pool_connection_failure(
        struct http_client_peer_pool *ppool, const char *reason)
 {
-       unsigned int pending;
-
-       /* count number of pending connections */
-       pending = array_count(&ppool->pending_conns);
-       i_assert(pending > 0);
-
        e_debug(ppool->event,
                "Failed to make connection "
                "(connections=%u, connecting=%u)",
-               array_count(&ppool->conns), pending);
+               array_count(&ppool->conns), array_count(&ppool->pending_conns));
 
        http_client_peer_shared_connection_failure(ppool->peer);
 
-       if (pending > 1) {
+       if (array_count(&ppool->pending_conns) > 0) {
                /* 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
@@ -507,7 +501,7 @@ http_client_peer_shared_connection_failure(
        pshared->last_failure = ioloop_timeval;
 
        /* manage backoff timer only when this was the only attempt */
-       if (pending == 1)
+       if (pending == 0)
                http_client_peer_shared_increase_backoff_timer(pshared);
 }