]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: init: never lower rlim_fd_max
authorWilly Tarreau <w@1wt.eu>
Fri, 1 Mar 2019 09:32:05 +0000 (10:32 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 1 Mar 2019 09:40:30 +0000 (10:40 +0100)
If a ulimit-n value is set, we must not lower the rlim_max value if the
new value is lower, we must only adjust the rlim_cur one. The effect is
that on very low values, this could prevent a master-worker reload, or
make an external check fail by lack of FDs.

This may be backported to 1.9 and earlier, but it depends on this patch
"MINOR: global: keep a copy of the initial rlim_fd_cur and rlim_fd_max
values".

src/haproxy.c

index 62263e482346256fe783a1d5e4f3fcf0e154ce49..0d42bc0b753900f319b8dc2993e84d2792ee0ea2 100644 (file)
@@ -2780,7 +2780,9 @@ int main(int argc, char **argv)
                global.rlimit_nofile = global.maxsock;
 
        if (global.rlimit_nofile) {
-               limit.rlim_cur = limit.rlim_max = global.rlimit_nofile;
+               limit.rlim_cur = global.rlimit_nofile;
+               limit.rlim_max = MAX(rlim_fd_max_at_boot, limit.rlim_cur);
+
                if (setrlimit(RLIMIT_NOFILE, &limit) == -1) {
                        /* try to set it to the max possible at least */
                        getrlimit(RLIMIT_NOFILE, &limit);