]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-http: client: peer: Determine number of pending peers in http_client_peer_shared_...
authorStephan Bosch <stephan.bosch@dovecot.fi>
Thu, 6 Sep 2018 00:51:09 +0000 (02:51 +0200)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Fri, 7 Sep 2018 06:18:56 +0000 (09:18 +0300)
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).

src/lib-http/http-client-peer.c

index 09bb87e44829bdcdecf1a28a92854438c00e36c6..e2b70c50dea632d8a532f2d71e77137d3ca16175 100644 (file)
@@ -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 */