Skip to content

Commit

Permalink
lib-http: client: peer: Properly handle claiming an existing connection.
Browse files Browse the repository at this point in the history
If no other connections were being created, request handling was not restarted.
This problem sometimes caused the client to hang.
Fixed by calling http_client_peer_connection_success() upon claiming an existing connection.
  • Loading branch information
stephanbosch committed Dec 13, 2017
1 parent 20138b8 commit af7956f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/lib-http/http-client-peer.c
Expand Up @@ -734,13 +734,15 @@ http_client_peer_do_connect(struct http_client_peer *peer,
struct http_client_peer_pool *ppool = peer->ppool;
struct http_client_connection *const *idle_conns;
unsigned int i, idle_count;
bool claimed_existing = FALSE;

if (count == 0)
return;

idle_conns = array_get(&ppool->idle_conns, &idle_count);
for (i = 0; i < count && i < idle_count; i++) {
http_client_connection_claim_idle(idle_conns[i], peer);
claimed_existing = TRUE;

e_debug(peer->event,
"Claimed idle connection (connections=%u)",
Expand All @@ -752,6 +754,9 @@ http_client_peer_do_connect(struct http_client_peer *peer,
"Making new connection %u of %u", i+1, count);
(void)http_client_connection_create(peer);
}

if (claimed_existing)
http_client_peer_connection_success(peer);
}

static void
Expand Down

0 comments on commit af7956f

Please sign in to comment.