MEDIUM: adjust the maxaccept per listener depending on the number of processes

global.tune.maxaccept was used for all listeners. This becomes really not
convenient when some listeners are bound to a single process and other ones
are bound to many processes.

Now we change the principle : we count the number of processes a listener
is bound to, and apply the maxaccept either entirely if there is a single
process, or divided by twice the number of processes in order to maintain
fairness.

The default limit has also been increased from 32 to 64 as it appeared that
on small machines, 32 was too low to achieve high connection rates.
diff --git a/src/cfgparse.c b/src/cfgparse.c
index 4ee5f89..10fc4a6 100644
--- a/src/cfgparse.c
+++ b/src/cfgparse.c
@@ -5957,6 +5957,7 @@
 		struct tcp_rule *trule;
 		struct listener *listener;
 		unsigned int next_id;
+		int nbproc;
 
 		if (curproxy->uuid < 0) {
 			/* proxy ID not set, use automatic numbering with first
@@ -5976,6 +5977,9 @@
 			continue;
 		}
 
+		/* number of processes this proxy is bound to */
+		nbproc = curproxy->bind_proc ? popcount(curproxy->bind_proc) : global.nbproc;
+
 		switch (curproxy->mode) {
 		case PR_MODE_HEALTH:
 			cfgerr += proxy_cfg_ensure_no_http(curproxy);
@@ -6817,6 +6821,22 @@
 				listener->maxconn = curproxy->maxconn;
 			if (!listener->backlog)
 				listener->backlog = curproxy->backlog;
+			if (!listener->maxaccept)
+				listener->maxaccept = global.tune.maxaccept ? global.tune.maxaccept : 64;
+
+			/* we want to have an optimal behaviour on single process mode to
+			 * maximize the work at once, but in multi-process we want to keep
+			 * some fairness between processes, so we target half of the max
+			 * number of events to be balanced over all the processes the proxy
+			 * is bound to. Rememeber that maxaccept = -1 must be kept as it is
+			 * used to disable the limit.
+			 */
+			if (listener->maxaccept > 0) {
+				if (nbproc > 1)
+					listener->maxaccept = (listener->maxaccept + 1) / 2;
+				listener->maxaccept = (listener->maxaccept + nbproc - 1) / nbproc;
+			}
+
 			listener->timeout = &curproxy->timeout.client;
 			listener->accept = session_accept;
 			listener->handler = process_session;