BUG/MINOR: limits: compute_ideal_maxconn: don't cap remain if fd_hard_limit=0
authorValentine Krasnobaeva <vkrasnobaeva@haproxy.com>
Tue, 18 Mar 2025 15:33:54 +0000 (16:33 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 28 May 2025 10:07:41 +0000 (12:07 +0200)
commitc57aab7218dbb0c5e20733562ed921d6eeaf66cd
tree2cf31ab418f445d75d727b1a97658ad832575c1e
parent27d9b7691ee4ea59b662859cd4f17a6178d2f578
BUG/MINOR: limits: compute_ideal_maxconn: don't cap remain if fd_hard_limit=0

'global.fd_hard_limit' stays uninitialized, if haproxy is started with -m
(global.rlimit_memmax). 'remain' is the MAX between soft and hard process fd
limits. It will be always bigger than 'global.fd_hard_limit' (0) in this case.

So, if we reassign 'remain' to the 'global.fd_hard_limit' unconditionally,
calculated then 'maxconn' will be even negative and the DEFAULT_MAXCONN (100)
will be set as the 'ideal_maxconn'.

During the 'global.maxconn' calculations in set_global_maxconn(), if the
provided 'global.rlimit_memmax' is quite big, system will refuse to calculate
based on its 'global.maxconn' and we will do a fallback to the 'ideal_maxconn',
which is 100.

Same problem for the configs with SSL frontends and backends.

This fixes the issue #2899.

This should be backported to v3.1.0.

(cherry picked from commit 060f441199aa97d9735dd553bafd231ca615f723)
Signed-off-by: Willy Tarreau <w@1wt.eu>
(cherry picked from commit 95197ec04e241f33803909c9c6182e832b6ed16e)
[cf: Applied on src/haproxy.c]
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
src/haproxy.c