mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-20 21:31:28 +02:00
BUG/MINOR: mworker: be careful to restore the original rlim_fd_cur/max on reload
When the master re-execs itself on reload, it doesn't restore the initial rlim_fd_cur/rlim_fd_max values, which have been modified by the ulimit-n or global maxconn directives. This is a problem, because if these values were set really low it could prevent the process from restarting, and if they were set very high, this could have some implications on the restart time, or later on the computed maxconn. Let's simply reset these values to the ones we had at boot to maintain the system in a consistent state. A backport could be performed to 1.9 and maybe 1.8. This patch depends on the two previous ones.
This commit is contained in:
parent
9f6dc72477
commit
8dca19549a
@ -716,6 +716,7 @@ void mworker_reload()
|
||||
int next_argc = 0;
|
||||
int j;
|
||||
char *msg = NULL;
|
||||
struct rlimit limit;
|
||||
struct per_thread_deinit_fct *ptdf;
|
||||
|
||||
mworker_block_signals();
|
||||
@ -739,6 +740,16 @@ void mworker_reload()
|
||||
if (fdtab)
|
||||
deinit_pollers();
|
||||
|
||||
/* restore the initial FD limits */
|
||||
limit.rlim_cur = rlim_fd_cur_at_boot;
|
||||
limit.rlim_max = rlim_fd_max_at_boot;
|
||||
if (setrlimit(RLIMIT_NOFILE, &limit) == -1) {
|
||||
getrlimit(RLIMIT_NOFILE, &limit);
|
||||
ha_warning("Failed to restore initial FD limits (cur=%u max=%u), using cur=%u max=%u\n",
|
||||
rlim_fd_cur_at_boot, rlim_fd_max_at_boot,
|
||||
(unsigned int)limit.rlim_cur, (unsigned int)limit.rlim_max);
|
||||
}
|
||||
|
||||
/* compute length */
|
||||
while (next_argv[next_argc])
|
||||
next_argc++;
|
||||
|
Loading…
x
Reference in New Issue
Block a user