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.
This commit is contained in:
Valentine Krasnobaeva 2024-07-10 12:15:45 +02:00 committed by Willy Tarreau
parent a4bc71a1a3
commit 1517bcb5e3
5 changed files with 29 additions and 1 deletions

View File

@ -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

12
include/haproxy/limits.h Normal file
View File

@ -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 <sys/resource.h>
#endif /* _HAPROXY_LIMITS_H */

View File

@ -32,6 +32,7 @@
#include <haproxy/errors.h>
#include <haproxy/global.h>
#include <haproxy/list.h>
#include <haproxy/limits.h>
#include <haproxy/proxy.h>
#include <haproxy/server.h>
#include <haproxy/signal.h>

View File

@ -92,6 +92,7 @@
#include <haproxy/global.h>
#include <haproxy/hlua.h>
#include <haproxy/http_rules.h>
#include <haproxy/limits.h>
#if defined(USE_LINUX_CAP)
#include <haproxy/linuxcap.h>
#endif

13
src/limits.c Normal file
View File

@ -0,0 +1,13 @@
/*
* Handlers for process resources limits.
*
* SPDX-License-Identifier: GPL-2.0-or-later.
*
*/
#include <haproxy/compat.h>
#include <haproxy/global.h>
#include <haproxy/limits.h>
#include <haproxy/proxy.h>