From 22db643648ec2abc250cb5581ab50ee6a8076b89 Mon Sep 17 00:00:00 2001 From: Valentine Krasnobaeva Date: Wed, 10 Jul 2024 12:51:08 +0200 Subject: [PATCH] MINOR: haproxy: prepare to move limits-related code This patch is done in order to prepare the move of handlers to compute and to check process related limits as maxconn, maxsock, maxpipes. So, these handlers become no longer static due to the future move. We add the handlers declarations in limits.h in this patch as well, in order to keep the next patch, dedicated to code replacement, without any additional modifications. Such split also assures that this patch can be compiled separately from the next one, where we moving the handlers. This is important in case of git-bisect. --- include/haproxy/limits.h | 8 ++++++++ src/haproxy.c | 8 ++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/include/haproxy/limits.h b/include/haproxy/limits.h index f9ff625f3..50937a32a 100644 --- a/include/haproxy/limits.h +++ b/include/haproxy/limits.h @@ -12,6 +12,14 @@ extern unsigned int rlim_fd_cur_at_boot; extern unsigned int rlim_fd_max_at_boot; +/* handlers to compute internal process limits, if they are not provided via + * cmd line or via configuration file. +*/ +int compute_ideal_maxpipes(); +int compute_ideal_maxconn(); +int compute_ideal_maxsock(int maxconn); +int check_if_maxsock_permitted(int maxsock); + /* handlers to manipulate system resources limits granted by OS to process and * to tie them up with the internal process limits */ diff --git a/src/haproxy.c b/src/haproxy.c index 4c63c22f6..ea53f9130 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -1445,7 +1445,7 @@ static void ha_random_boot(char *const *argv) * Note that a value of zero means there is no need for pipes. -1 is never * returned if global.maxconn is valid. */ -static int compute_ideal_maxpipes() +int compute_ideal_maxpipes() { struct proxy *cur; int nbfe = 0, nbbe = 0; @@ -1494,7 +1494,7 @@ static int compute_ideal_maxpipes() * used to rely on this value as the default one. The system will emit a * warning indicating how many FDs are missing anyway if needed. */ -static int compute_ideal_maxconn() +int compute_ideal_maxconn() { int ssl_sides = !!global.ssl_used_frontend + !!global.ssl_used_backend; int engine_fds = global.ssl_used_async_engines * ssl_sides; @@ -1574,7 +1574,7 @@ static int compute_ideal_maxconn() * temporarily change global.maxconn for the time needed to propagate the * computations, and will reset it. */ -static int compute_ideal_maxsock(int maxconn) +int compute_ideal_maxsock(int maxconn) { int maxpipes = global.maxpipes; int maxsock = global.maxsock; @@ -1610,7 +1610,7 @@ static int compute_ideal_maxsock(int maxconn) * that the setting is possible, so that we defer the error processing to the * final stage in charge of enforcing this. */ -static int check_if_maxsock_permitted(int maxsock) +int check_if_maxsock_permitted(int maxsock) { struct rlimit orig_limit, test_limit; int ret;