From 1732a603c6a95a09a173dec05c5b1f1a4dad1ef7 Mon Sep 17 00:00:00 2001 From: Stephan Bosch Date: Thu, 6 Sep 2018 03:11:18 +0200 Subject: [PATCH] lib-http: client: peer: Always run http_client_queue_connection_failure() upon definitive connection failure. The recorded peer->connecting flag was highly unreliable in a scenario involving starting parallel connections. This way, the linked queues can update their state accordingly. Also, this will not cause empty queues to initiate new connection, because empty queues will do nothing after updating the connection state. This problem caused a client ioloop hang in high-load conditions. --- src/lib-http/http-client-peer.c | 10 ---------- src/lib-http/http-client-private.h | 1 - 2 files changed, 11 deletions(-) diff --git a/src/lib-http/http-client-peer.c b/src/lib-http/http-client-peer.c index f652598843..a2ce1f5d7b 100644 --- a/src/lib-http/http-client-peer.c +++ b/src/lib-http/http-client-peer.c @@ -785,8 +785,6 @@ http_client_peer_connect_backoff(struct http_client_peer *peer) static void http_client_peer_connect(struct http_client_peer *peer, unsigned int count) { - peer->connecting = TRUE; - if (http_client_peer_shared_start_backoff_timer(peer->shared)) { peer->connect_backoff = TRUE; return; @@ -818,8 +816,6 @@ http_client_peer_cancel(struct http_client_peer *peer) e_debug(peer->event, "Peer cancel"); - peer->connecting = FALSE; - /* make a copy of the connection array; freed connections modify it */ t_array_init(&conns, array_count(&peer->conns)); array_copy(&conns.arr, 0, &peer->conns.arr, 0, array_count(&peer->conns)); @@ -1191,8 +1187,6 @@ void http_client_peer_connection_success(struct http_client_peer *peer) struct http_client_peer_pool *ppool = peer->ppool; struct http_client_queue *const *queue; - peer->connecting = FALSE; - http_client_peer_pool_connection_success(ppool); e_debug(peer->event, "Successfully connected (connections=%u)", @@ -1218,10 +1212,6 @@ http_client_peer_connection_failed_any(struct http_client_peer *peer, { struct http_client_queue *const *queue; - if (!peer->connecting) - return; - peer->connecting = FALSE; - e_debug(peer->event, "Connection failed: %s", reason); /* failed to make any connection. a second connect will probably also diff --git a/src/lib-http/http-client-private.h b/src/lib-http/http-client-private.h index 85e7a4d574..eee47cb9fe 100644 --- a/src/lib-http/http-client-private.h +++ b/src/lib-http/http-client-private.h @@ -278,7 +278,6 @@ struct http_client_peer { /* zero time-out for consolidating request handling */ struct timeout *to_req_handling; - bool connecting:1; /* peer is waiting to be connected */ bool connect_backoff:1; /* peer is waiting for backoff timout*/ bool disconnected:1; /* peer is already disconnected */ bool handling_requests:1;/* currently running request handler */ -- 2.47.3