]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: queues: Check minconn first in srv_dynamic_maxconn()
authorOlivier Houchard <ohouchard@haproxy.com>
Wed, 11 Feb 2026 06:53:21 +0000 (07:53 +0100)
committerOlivier Houchard <ohouchard@haproxy.com>
Thu, 12 Feb 2026 01:18:59 +0000 (02:18 +0100)
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.

src/queue.c

index 849bd52f396f6dcc4b6689f0887358b3cd698fd4..1fa40ed34c5b0b9e0f44b31ed7221a5641f60579 100644 (file)
@@ -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);