From 29af08a693dabe12d9a995a7720a68a9521318ae Mon Sep 17 00:00:00 2001 From: Stephan Bosch Date: Thu, 6 Sep 2018 03:23:26 +0200 Subject: [PATCH] lib-http: client: connection: Unlist the connection as pending immediately in http_client_connection_failure(). --- src/lib-http/http-client-connection.c | 1 + src/lib-http/http-client-peer.c | 12 +++--------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/lib-http/http-client-connection.c b/src/lib-http/http-client-connection.c index fd4208f5a9..f7059ca9af 100644 --- a/src/lib-http/http-client-connection.c +++ b/src/lib-http/http-client-connection.c @@ -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); } diff --git a/src/lib-http/http-client-peer.c b/src/lib-http/http-client-peer.c index 180a9006b1..afa71e94ec 100644 --- a/src/lib-http/http-client-peer.c +++ b/src/lib-http/http-client-peer.c @@ -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); }