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.
diff --git a/src/haproxy.c b/src/haproxy.c
index 0d42bc0..40865f0 100644
--- a/src/haproxy.c
+++ b/src/haproxy.c
@@ -716,6 +716,7 @@
 	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 @@
 	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++;