From: Stephan Bosch Date: Thu, 6 Sep 2018 00:51:09 +0000 (+0200) Subject: lib-http: client: peer: Determine number of pending peers in http_client_peer_shared_... X-Git-Tag: 2.3.4~225 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a2f5b4314fef18ea148bb77b74161b165a99c9cf;p=thirdparty%2Fdovecot%2Fcore.git lib-http: client: peer: Determine number of pending peers in http_client_peer_shared_connection_failure() itself. Before, the number of pending peers was a parameter, but that was only for a single peer pool. This is wrong, since the one peer can have many different pools (depending on how many clients with incompatible configs share this peer). --- diff --git a/src/lib-http/http-client-peer.c b/src/lib-http/http-client-peer.c index 09bb87e448..e2b70c50de 100644 --- a/src/lib-http/http-client-peer.c +++ b/src/lib-http/http-client-peer.c @@ -22,7 +22,7 @@ http_client_peer_shared_connection_success( struct http_client_peer_shared *pshared); static void http_client_peer_shared_connection_failure( - struct http_client_peer_shared *pshared, unsigned int pending); + struct http_client_peer_shared *pshared); static void http_client_peer_connection_failed_any(struct http_client_peer *peer, const char *reason); @@ -236,7 +236,7 @@ http_client_peer_pool_connection_failure( "(connections=%u, connecting=%u)", array_count(&ppool->conns), pending); - http_client_peer_shared_connection_failure(ppool->peer, pending); + http_client_peer_shared_connection_failure(ppool->peer); if (pending > 1) { /* if there are other connections attempting to connect, wait @@ -471,8 +471,18 @@ http_client_peer_shared_connection_success( static void http_client_peer_shared_connection_failure( - struct http_client_peer_shared *pshared, unsigned int pending) + struct http_client_peer_shared *pshared) { + struct http_client_peer_pool *ppool; + unsigned int pending = 0; + + /* determine the number of connections still pending */ + ppool = pshared->pools_list; + while (ppool != NULL) { + pending += array_count(&ppool->pending_conns); + ppool = ppool->next; + } + pshared->last_failure = ioloop_timeval; /* manage backoff timer only when this was the only attempt */