]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-http: client: peer: Always run http_client_queue_connection_failure() upon defini...
authorStephan Bosch <stephan.bosch@dovecot.fi>
Thu, 6 Sep 2018 01:11:18 +0000 (03:11 +0200)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Fri, 7 Sep 2018 06:18:56 +0000 (09:18 +0300)
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
src/lib-http/http-client-private.h

index f65259884396e3fcacbbc9dfa371ff9738524759..a2ce1f5d7b80d3fc3745ef94ccde5eac84d0e67e 100644 (file)
@@ -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
index 85e7a4d574dc704a10cb0e3c55e2a5c5ff9b6416..eee47cb9fe2c2781edff34c02dff5adbc16b2355 100644 (file)
@@ -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 */