BUG/MINOR: init: ensure that FD limit is raised to the max allowed

When the requested amount of FDs cannot be allocated, setrlimit() fails.
That's bad because if the limit is set to 1024 and we need 10000, we
stay on 1024 while we could possibly raise it to 4096 thanks to rlim_max.
This patch takes care of trying to assign rlim_cur to rlim_max on failure
so that we get as much as possible if we can't get all we need. The case
is particularly visible when starting haproxy as a non-privileged user
and a large maxconn is specified in the configuration.

Another point of doing this is that it is the only way to allow us to
close inherited FDs upon fork(), ie those between rlim_cur and rlim_max.

This patch may be backported to 1.6 and 1.5.
(cherry picked from commit 164dd0b6e4ad36dc90e9163eeb84d3fb4aa175e9)
(cherry picked from commit 1c3667de938516ff5c778ef5279e8620b2df77fd)
1 file changed