From 1517bcb5e3ef5bea93b0e7f64033b51240fdeb24 Mon Sep 17 00:00:00 2001 From: Valentine Krasnobaeva Date: Wed, 10 Jul 2024 12:15:45 +0200 Subject: [PATCH] MINOR: limits: prepare to keep limits in one place The code which gets, sets and checks initial and current fd limits and process related limits (maxconn, maxsock, ulimit-n, fd-hard-limit) is spread around different functions in haproxy.c and in fd.c. Let's group it together in dedicated limits.c and limits.h. This patch is done in order to prepare the moving of limits-related functions from different places to the new 'limits' compilation unit. It helps to keep clean the next patch, which will do only the move without any additional modifications. Such detailed split is needed in order to be sure not to break accidentally limits logic and in order to be able to compile each commit separately in case of git-bisect. --- Makefile | 3 ++- include/haproxy/limits.h | 12 ++++++++++++ src/extcheck.c | 1 + src/haproxy.c | 1 + src/limits.c | 13 +++++++++++++ 5 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 include/haproxy/limits.h create mode 100644 src/limits.c diff --git a/Makefile b/Makefile index ab3f3b1d3..1178229eb 100644 --- a/Makefile +++ b/Makefile @@ -982,7 +982,8 @@ OBJS += src/mux_h2.o src/mux_h1.o src/mux_fcgi.o src/stream.o \ src/hpack-tbl.o src/ebsttree.o src/ebistree.o src/auth.o \ src/hpack-huff.o src/freq_ctr.o src/dict.o src/wdt.o \ src/pipe.o src/init.o src/http_acl.o src/hpack-enc.o \ - src/ebtree.o src/dgram.o src/hash.o src/version.o + src/ebtree.o src/dgram.o src/hash.o src/version.o \ + src/limits.o ifneq ($(TRACE),) OBJS += src/calltrace.o diff --git a/include/haproxy/limits.h b/include/haproxy/limits.h new file mode 100644 index 000000000..2a76e2c95 --- /dev/null +++ b/include/haproxy/limits.h @@ -0,0 +1,12 @@ +/* + * Handlers for process resources limits. + * + * SPDX-License-Identifier: GPL-2.0-or-later. + * + */ + +#ifndef _HAPROXY_LIMITS_H +#define _HAPROXY_LIMITS_H +#include + +#endif /* _HAPROXY_LIMITS_H */ diff --git a/src/extcheck.c b/src/extcheck.c index c667b1635..05c53ff9f 100644 --- a/src/extcheck.c +++ b/src/extcheck.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include diff --git a/src/haproxy.c b/src/haproxy.c index 8fdc4b860..cf23dba52 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -92,6 +92,7 @@ #include #include #include +#include #if defined(USE_LINUX_CAP) #include #endif diff --git a/src/limits.c b/src/limits.c new file mode 100644 index 000000000..a80a2ac21 --- /dev/null +++ b/src/limits.c @@ -0,0 +1,13 @@ +/* + * Handlers for process resources limits. + * + * SPDX-License-Identifier: GPL-2.0-or-later. + * + */ + +#include +#include +#include +#include + +