MINOR: listener: do not needlessly set l->maxconn

It's pointless to always set and maintain l->maxconn because the accept
loop already enforces the frontend's limit anyway. Thus let's stop setting
this value by default and keep it to zero meaning "no limit". This way the
frontend's maxconn will be used by default. Of course if a value is set,
it will be enforced.
diff --git a/src/cfgparse.c b/src/cfgparse.c
index 4c8b48b..e29ab97 100644
--- a/src/cfgparse.c
+++ b/src/cfgparse.c
@@ -649,7 +649,6 @@
 			}
 			l = LIST_ELEM(bind_conf->listeners.n, typeof(l), by_bind);
 			l->maxaccept = 1;
-			l->maxconn = curpeers->peers_fe->maxconn;
 			l->accept = session_accept_fd;
 			l->analysers |=  curpeers->peers_fe->fe_req_ana;
 			l->default_target = curpeers->peers_fe->default_target;
@@ -852,7 +851,6 @@
 
 		l = LIST_ELEM(bind_conf->listeners.n, typeof(l), by_bind);
 		l->maxaccept = 1;
-		l->maxconn = curpeers->peers_fe->maxconn;
 		l->accept = session_accept_fd;
 		l->analysers |=  curpeers->peers_fe->fe_req_ana;
 		l->default_target = curpeers->peers_fe->default_target;
@@ -3739,8 +3737,6 @@
 
 			if (curproxy->options & PR_O_TCP_NOLING)
 				listener->options |= LI_O_NOLINGER;
-			if (!listener->maxconn)
-				listener->maxconn = curproxy->maxconn;
 			if (!listener->maxaccept)
 				listener->maxaccept = global.tune.maxaccept ? global.tune.maxaccept : 64;
 
diff --git a/src/cli.c b/src/cli.c
index 9b95718..def5eba 100644
--- a/src/cli.c
+++ b/src/cli.c
@@ -297,7 +297,6 @@
 		}
 
 		list_for_each_entry(l, &bind_conf->listeners, by_bind) {
-			l->maxconn = global.stats_fe->maxconn;
 			l->accept = session_accept_fd;
 			l->default_target = global.stats_fe->default_target;
 			l->options |= LI_O_UNLIMITED; /* don't make the peers subject to global limits */
@@ -2520,7 +2519,6 @@
 
 
 	list_for_each_entry(l, &bind_conf->listeners, by_bind) {
-		l->maxconn = 10;
 		l->accept = session_accept_fd;
 		l->default_target = mworker_proxy->default_target;
 		/* don't make the peers subject to global limits and don't close it in the master */
@@ -2589,7 +2587,6 @@
 	path = NULL;
 
 	list_for_each_entry(l, &bind_conf->listeners, by_bind) {
-		l->maxconn = global.stats_fe->maxconn;
 		l->accept = session_accept_fd;
 		l->default_target = global.stats_fe->default_target;
 		l->options |= (LI_O_UNLIMITED | LI_O_NOSTOP);
diff --git a/src/listener.c b/src/listener.c
index 4e22e50..9a9699c 100644
--- a/src/listener.c
+++ b/src/listener.c
@@ -234,7 +234,7 @@
 				listener->state = LI_LISTEN;
 			}
 		}
-		else if (listener->nbconn < listener->maxconn) {
+		else if (!listener->maxconn || listener->nbconn < listener->maxconn) {
 			fd_want_recv(listener->fd);
 			listener->state = LI_READY;
 		}
@@ -360,7 +360,7 @@
 
 	LIST_DEL_LOCKED(&l->wait_queue);
 
-	if (l->nbconn >= l->maxconn) {
+	if (l->maxconn && l->nbconn >= l->maxconn) {
 		l->state = LI_FULL;
 		goto end;
 	}
@@ -682,7 +682,7 @@
 		 */
 		do {
 			count = l->nbconn;
-			if (count >= l->maxconn) {
+			if (l->maxconn && count >= l->maxconn) {
 				/* the listener was marked full or another
 				 * thread is going to do it.
 				 */
@@ -692,7 +692,7 @@
 			next_conn = count + 1;
 		} while (!HA_ATOMIC_CAS(&l->nbconn, &count, next_conn));
 
-		if (next_conn == l->maxconn) {
+		if (l->maxconn && next_conn == l->maxconn) {
 			/* we filled it, mark it full */
 			listener_full(l);
 		}
@@ -942,7 +942,7 @@
 	if (next_actconn)
 		HA_ATOMIC_SUB(&actconn, 1);
 
-	if ((l->state == LI_FULL && l->nbconn < l->maxconn) ||
+	if ((l->state == LI_FULL && (!l->maxconn || l->nbconn < l->maxconn)) ||
 	    (l->state == LI_LIMITED && ((!p || p->feconn < p->maxconn) && (actconn < global.maxconn)))) {
 		/* at least one thread has to this when quitting */
 		resume_listener(l);
@@ -1212,8 +1212,8 @@
 	}
 
 	val = atol(args[cur_arg + 1]);
-	if (val <= 0) {
-		memprintf(err, "'%s' : invalid value %d, must be > 0", args[cur_arg], val);
+	if (val < 0) {
+		memprintf(err, "'%s' : invalid value %d, must be >= 0", args[cur_arg], val);
 		return ERR_ALERT | ERR_FATAL;
 	}
 
diff --git a/src/peers.c b/src/peers.c
index dc5bdea..743bce8 100644
--- a/src/peers.c
+++ b/src/peers.c
@@ -2551,14 +2551,11 @@
 int peers_init_sync(struct peers *peers)
 {
 	struct peer * curpeer;
-	struct listener *listener;
 
 	for (curpeer = peers->remote; curpeer; curpeer = curpeer->next) {
 		peers->peers_fe->maxconn += 3;
 	}
 
-	list_for_each_entry(listener, &peers->peers_fe->conf.listeners, by_fe)
-		listener->maxconn = peers->peers_fe->maxconn;
 	peers->sync_task = task_new(MAX_THREADS_MASK);
 	if (!peers->sync_task)
 		return 0;
diff --git a/src/proxy.c b/src/proxy.c
index 78e099e..d3c0698 100644
--- a/src/proxy.c
+++ b/src/proxy.c
@@ -1884,7 +1884,8 @@
 
 	px->maxconn = v;
 	list_for_each_entry(l, &px->conf.listeners, by_fe) {
-		l->maxconn = v;
+		if (l->maxconn)
+			l->maxconn = v;
 		if (l->state == LI_FULL)
 			resume_listener(l);
 	}
diff --git a/src/stats.c b/src/stats.c
index a7c12e1..26b1450 100644
--- a/src/stats.c
+++ b/src/stats.c
@@ -1472,7 +1472,7 @@
 	stats[ST_F_EREQ]     = mkf_u64(FN_COUNTER, l->counters->failed_req);
 	stats[ST_F_DCON]     = mkf_u64(FN_COUNTER, l->counters->denied_conn);
 	stats[ST_F_DSES]     = mkf_u64(FN_COUNTER, l->counters->denied_sess);
-	stats[ST_F_STATUS]   = mkf_str(FO_STATUS, (l->nbconn < l->maxconn) ? (l->state == LI_LIMITED) ? "WAITING" : "OPEN" : "FULL");
+	stats[ST_F_STATUS]   = mkf_str(FO_STATUS, (!l->maxconn || l->nbconn < l->maxconn) ? (l->state == LI_LIMITED) ? "WAITING" : "OPEN" : "FULL");
 	stats[ST_F_PID]      = mkf_u32(FO_KEY, relative_pid);
 	stats[ST_F_IID]      = mkf_u32(FO_KEY|FS_SERVICE, px->uuid);
 	stats[ST_F_SID]      = mkf_u32(FO_KEY|FS_SERVICE, l->luid);