]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: global: keep a copy of the initial rlim_fd_cur and rlim_fd_max values
authorWilly Tarreau <w@1wt.eu>
Fri, 1 Mar 2019 09:09:28 +0000 (10:09 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 1 Mar 2019 09:40:30 +0000 (10:40 +0100)
Let's keep a copy of these initial values. They will be useful to
compute automatic maxconn, as well as to restore proper limits when
doing an execve() on external checks.

include/types/global.h
src/haproxy.c

index 503d8f988598939572e59a775165b0fc58c5b975..009814bcbb11996062d16776c44a8bdac42f6e10 100644 (file)
@@ -222,6 +222,8 @@ extern volatile unsigned long sleeping_thread_mask;
 extern struct list proc_list; /* list of process in mworker mode */
 extern struct mworker_proc *proc_self; /* process structure of current process */
 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;
 
 /* bit values to go with "warned" above */
 #define WARN_BLOCK_DEPRECATED       0x00000001
index 59da1fda6904b533a3fdeb7db19f5df5be49a5e5..62263e482346256fe783a1d5e4f3fcf0e154ce49 100644 (file)
@@ -220,6 +220,8 @@ static char **next_argv = NULL;
 struct list proc_list = LIST_HEAD_INIT(proc_list);
 
 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;
 
 struct mworker_proc *proc_self = NULL;
 
@@ -2748,6 +2750,11 @@ int main(int argc, char **argv)
                exit(1);
        }
 
+       /* take a copy of initial limits before we possibly change them */
+       getrlimit(RLIMIT_NOFILE, &limit);
+       rlim_fd_cur_at_boot = limit.rlim_cur;
+       rlim_fd_max_at_boot = limit.rlim_max;
+
        /* process all initcalls in order of potential dependency */
        RUN_INITCALLS(STG_PREPARE);
        RUN_INITCALLS(STG_LOCK);