Skip to content

Commit

Permalink
lib-http: client: peer: Determine number of pending peers in http_cli…
Browse files Browse the repository at this point in the history
…ent_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).
  • Loading branch information
stephanbosch authored and villesavolainen committed Sep 7, 2018
1 parent 41925f3 commit a2f5b43
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/lib-http/http-client-peer.c
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 */
Expand Down

0 comments on commit a2f5b43

Please sign in to comment.