BUG/MEDIUM: mworker: use default maxconn in wait mode

In bug #1751, it was reported that haproxy is consumming too much memory
since the 2.4 version. This is because of a change in the master, which
loses completely its configuration in wait mode, and lose its maxconn.

Without the maxconn, haproxy will try to compute one itself, and will
allocate RAM consequently, too much in our case. Which means the master
will have a too high maxconn and too much RAM allocated.

The patch fixes the issue by setting the maxconn to the default value
when re-executing the master in wait mode.

Must be backported as far as 2.5.

(cherry picked from commit 0a012aa16b77af4039988e80e7343ec2eec267dc)
Signed-off-by: Amaury Denoyelle <adenoyelle@haproxy.com>
(cherry picked from commit 42d5a4382eab523cb79aa58b9c29203da370ea51)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 92c10cc0cf2b615a074922290746d8e113b515e1)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
diff --git a/src/haproxy.c b/src/haproxy.c
index b484195..4ee443e 100644
--- a/src/haproxy.c
+++ b/src/haproxy.c
@@ -2080,6 +2080,10 @@
 			exit(1);
 	}
 
+	/* set the default maxconn in the master, but let it be rewritable with -n */
+	if (global.mode & MODE_MWORKER_WAIT)
+		global.maxconn = DEFAULT_MAXCONN;
+
 	if (cfg_maxconn > 0)
 		global.maxconn = cfg_maxconn;