From: Olivier Houchard Date: Wed, 11 Feb 2026 06:53:21 +0000 (+0100) Subject: MINOR: queues: Check minconn first in srv_dynamic_maxconn() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a8f50cff7e2f0678abd0eb0d5f402dc6e3f1a870;p=thirdparty%2Fhaproxy.git MINOR: queues: Check minconn first in srv_dynamic_maxconn() In srv_dynamic_maxconn(), we'll decide that the max number of connection is the server's maxconn if 1) the proxy's number of connection is over fullconn, or if minconn was not set. Check if minconn is not set first, as it will be true most of the time, and as the proxy's "beconn" variable is in a busy cache line, it can be costly to access it, while minconn/maxconn is in a cache line that should very rarely change. --- diff --git a/src/queue.c b/src/queue.c index 849bd52f3..1fa40ed34 100644 --- a/src/queue.c +++ b/src/queue.c @@ -105,11 +105,8 @@ unsigned int srv_dynamic_maxconn(const struct server *s) { unsigned int max; - if (s->proxy->beconn >= s->proxy->fullconn) - /* no fullconn or proxy is full */ - max = s->maxconn; - else if (s->minconn == s->maxconn) - /* static limit */ + if (s->minconn == s->maxconn || s->proxy->beconn >= s->proxy->fullconn) + /* static limit, or no fullconn or proxy is full */ max = s->maxconn; else max = MAX(s->minconn, s->proxy->beconn * s->maxconn / s->proxy->fullconn);