Skip to content

Commit

Permalink
lib-http: client: connection: Unlist the connection as pending immedi…
Browse files Browse the repository at this point in the history
…ately in http_client_connection_failure().
  • Loading branch information
stephanbosch authored and sirainen committed Sep 6, 2018
1 parent 4f512a7 commit 29af08a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/lib-http/http-client-connection.c
Expand Up @@ -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);
}

Expand Down
12 changes: 3 additions & 9 deletions src/lib-http/http-client-peer.c
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit 29af08a

Please sign in to comment.