From: Stephan Bosch Date: Wed, 12 Aug 2020 15:10:20 +0000 (+0200) Subject: lib-http: http-client-connection - Restructure http_client_connection_check_idle(). X-Git-Tag: 2.3.13~277 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9ead85be5b5565c5d7b15eccd49b287a1cc440f3;p=thirdparty%2Fdovecot%2Fcore.git lib-http: http-client-connection - Restructure http_client_connection_check_idle(). --- diff --git a/src/lib-http/http-client-connection.c b/src/lib-http/http-client-connection.c index eb6e72b504..fe3525dffe 100644 --- a/src/lib-http/http-client-connection.c +++ b/src/lib-http/http-client-connection.c @@ -479,7 +479,6 @@ void http_client_connection_check_idle(struct http_client_connection *conn) struct http_client_peer_pool *ppool = conn->ppool; struct http_client *client; const struct http_client_settings *set; - unsigned int timeout, count; peer = conn->peer; if (peer == NULL) { @@ -500,6 +499,8 @@ void http_client_connection_check_idle(struct http_client_connection *conn) array_count(&conn->request_wait_list) == 0 && !conn->in_req_callback && conn->incoming_payload == NULL && set->max_idle_time_msecs > 0) { + unsigned int timeout, count, max; + i_assert(peer != NULL); client = peer->client; @@ -510,9 +511,11 @@ void http_client_connection_check_idle(struct http_client_connection *conn) count = array_count(&peer->conns); i_assert(count > 0); + max = set->max_parallel_connections; + i_assert(max > 0); /* Set timeout for this connection */ - if (count > set->max_parallel_connections) { + if (count > max) { /* Instant death for (urgent) connections above limit */ timeout = 0; } else { @@ -521,10 +524,8 @@ void http_client_connection_check_idle(struct http_client_connection *conn) /* Kill duplicate connections quicker; linearly based on the number of connections */ i_assert(array_count(&ppool->conns) >= idle_count + 1); - timeout = - ((set->max_parallel_connections - idle_count) * - (set->max_idle_time_msecs / - set->max_parallel_connections)); + timeout = ((max - idle_count) * + (set->max_idle_time_msecs / max)); } e_debug(conn->event,