BUG/MEDIUM: init: fix fd_hard_limit default in compute_ideal_maxconn
authorValentine Krasnobaeva <vkrasnobaeva@haproxy.com>
Fri, 5 Jul 2024 18:42:09 +0000 (20:42 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 29 Jul 2024 12:20:15 +0000 (14:20 +0200)
commitbfd43e79996fd1aebed8942c2c27456e380f88e4
treec5b5d2c7707e0994b2cedc81206425ad8c5333eb
parentd6c8f7d7ae18a52783febde97b91291e5e211c65
BUG/MEDIUM: init: fix fd_hard_limit default in compute_ideal_maxconn

This commit fixes 41275a691 ("MEDIUM: init: set default for fd_hard_limit via
DEFAULT_MAXFD").

fd_hard_limit is taken in account implicitly via 'ideal_maxconn' value in
all maxconn adjustements, when global.rlimit_memmax is set:

MIN(global.maxconn, capped by global.rlimit_memmax, ideal_maxconn);

It also caps provided global.rlimit_nofile, if it couldn't be set as a current
process fd limit (see more details in the main() code).

So, lets set the default value for fd_hard_limit only, when there is no any
other haproxy-specific limit provided, i.e. rlimit_memmax, maxconn,
rlimit_nofile. Otherwise we may break users configs.

Please, note, that in master-worker mode, master does not need the
DEFAULT_MAXFD (1048576) as well, as we explicitly limit its maxconn to 100.

Must be backported in all stable versions until v2.6.0, including v2.6.0,
like the commit above.

(cherry picked from commit 16a5fac4bba1cb2bb6cf686066256aa141515feb)
Signed-off-by: Willy Tarreau <w@1wt.eu>
src/haproxy.c