From: Stephan Bosch Date: Wed, 12 Aug 2020 18:35:46 +0000 (+0200) Subject: lib-http: http-client-connection - Handle infinite idle timeout consistently. X-Git-Tag: 2.3.13~273 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6ea3dc6f410248b8072549791006ce92073160b5;p=thirdparty%2Fdovecot%2Fcore.git lib-http: http-client-connection - Handle infinite idle timeout consistently. --- diff --git a/src/lib-http/http-client-connection.c b/src/lib-http/http-client-connection.c index 5d4339b4ac..9e73f844d6 100644 --- a/src/lib-http/http-client-connection.c +++ b/src/lib-http/http-client-connection.c @@ -433,6 +433,9 @@ http_client_connection_start_idle_timeout(struct http_client_connection *conn) i_assert(conn->to_idle == NULL); + if (set->max_idle_time_msecs == 0) + return UINT_MAX; + count = array_count(&ppool->conns); i_assert(count > 0); max = http_client_peer_shared_max_connections(pshared); @@ -474,9 +477,13 @@ void http_client_connection_lost_peer(struct http_client_connection *conn) timeout = http_client_connection_start_idle_timeout(conn); - e_debug(conn->event, - "Lost peer; going idle (timeout = %u msecs)", - timeout); + if (timeout == UINT_MAX) + e_debug(conn->event, "Lost peer; going idle"); + else { + e_debug(conn->event, + "Lost peer; going idle (timeout = %u msecs)", + timeout); + } conn->idle = TRUE; array_push_back(&ppool->idle_conns, &conn); @@ -491,8 +498,6 @@ void http_client_connection_check_idle(struct http_client_connection *conn) { struct http_client_peer *peer; struct http_client_peer_pool *ppool = conn->ppool; - struct http_client *client; - const struct http_client_settings *set; peer = conn->peer; if (peer == NULL) { @@ -505,19 +510,13 @@ void http_client_connection_check_idle(struct http_client_connection *conn) return; } - client = peer->client; - set = &client->set; - if (conn->connected && array_is_created(&conn->request_wait_list) && array_count(&conn->request_wait_list) == 0 && - !conn->in_req_callback && conn->incoming_payload == NULL && - set->max_idle_time_msecs > 0) { + !conn->in_req_callback && conn->incoming_payload == NULL) { + struct http_client *client = peer->client; unsigned int timeout; - i_assert(peer != NULL); - client = peer->client; - i_assert(conn->to_requests == NULL); if (client->waiting) @@ -525,9 +524,14 @@ void http_client_connection_check_idle(struct http_client_connection *conn) timeout = http_client_connection_start_idle_timeout(conn); - e_debug(conn->event, - "No more requests queued; going idle " - "(timeout = %u msecs)", timeout); + if (timeout == UINT_MAX) { + e_debug(conn->event, + "No more requests queued; going idle"); + } else { + e_debug(conn->event, + "No more requests queued; going idle " + "(timeout = %u msecs)", timeout); + } conn->idle = TRUE; array_push_back(&ppool->idle_conns, &conn);