REORG: global: move rlim_fd_*_at_boot in limits

Let's move in 'limits' compilation unit global variables to keep the initial
process fd limits.
This commit is contained in:
Valentine Krasnobaeva 2024-07-10 12:41:26 +02:00 committed by Willy Tarreau
parent 47f2afb436
commit b8dc783eb9
4 changed files with 6 additions and 4 deletions

View File

@ -45,8 +45,6 @@ extern char *localpeer;
extern unsigned int warned; /* bitfield of a few warnings to emit just once */ extern unsigned int warned; /* bitfield of a few warnings to emit just once */
extern struct list proc_list; /* list of process in mworker mode */ extern struct list proc_list; /* list of process in mworker mode */
extern int master; /* 1 if in master, 0 otherwise */ extern int master; /* 1 if in master, 0 otherwise */
extern unsigned int rlim_fd_cur_at_boot;
extern unsigned int rlim_fd_max_at_boot;
extern int atexit_flag; extern int atexit_flag;
extern unsigned char boot_seed[20]; // per-boot random seed (160 bits initially) extern unsigned char boot_seed[20]; // per-boot random seed (160 bits initially)
extern THREAD_LOCAL struct buffer trash; extern THREAD_LOCAL struct buffer trash;

View File

@ -9,6 +9,9 @@
#define _HAPROXY_LIMITS_H #define _HAPROXY_LIMITS_H
#include <sys/resource.h> #include <sys/resource.h>
extern unsigned int rlim_fd_cur_at_boot;
extern unsigned int rlim_fd_max_at_boot;
/* handlers to manipulate system resources limits granted by OS to process and /* handlers to manipulate system resources limits granted by OS to process and
* to tie them up with the internal process limits * to tie them up with the internal process limits
*/ */

View File

@ -255,8 +255,6 @@ static char **old_argv = NULL; /* previous argv but cleaned up */
struct list proc_list = LIST_HEAD_INIT(proc_list); struct list proc_list = LIST_HEAD_INIT(proc_list);
int master = 0; /* 1 if in master, 0 if in child */ int master = 0; /* 1 if in master, 0 if in child */
unsigned int rlim_fd_cur_at_boot = 0;
unsigned int rlim_fd_max_at_boot = 0;
/* per-boot randomness */ /* per-boot randomness */
unsigned char boot_seed[20]; /* per-boot random seed (160 bits initially) */ unsigned char boot_seed[20]; /* per-boot random seed (160 bits initially) */

View File

@ -11,6 +11,9 @@
#include <haproxy/proxy.h> #include <haproxy/proxy.h>
unsigned int rlim_fd_cur_at_boot = 0;
unsigned int rlim_fd_max_at_boot = 0;
/* Sets the RLIMIT_NOFILE setting to <new_limit> and returns the previous one /* Sets the RLIMIT_NOFILE setting to <new_limit> and returns the previous one
* in <old_limit> if the pointer is not NULL, even if set_rlimit() fails. The * in <old_limit> if the pointer is not NULL, even if set_rlimit() fails. The
* two pointers may point to the same variable as the copy happens after * two pointers may point to the same variable as the copy happens after