diff --git a/src/cfgparse.c b/src/cfgparse.c index 4c8b48b1e..e29ab9764 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -649,7 +649,6 @@ int cfg_parse_peers(const char *file, int linenum, char **args, int kwm) } 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 @@ int cfg_parse_peers(const char *file, int linenum, char **args, int kwm) 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 @@ out_uri_auth_compat: 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 9b957186d..def5ebacc 100644 --- a/src/cli.c +++ b/src/cli.c @@ -297,7 +297,6 @@ static int stats_parse_global(char **args, int section_type, struct proxy *curpx } 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 @@ int mworker_cli_proxy_new_listener(char *line) 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 @@ int mworker_cli_sockpair_new(struct mworker_proc *mworker_proc, int proc) 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 4e22e507e..9a9699c94 100644 --- a/src/listener.c +++ b/src/listener.c @@ -234,7 +234,7 @@ static void enable_listener(struct listener *listener) 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 @@ int resume_listener(struct listener *l) 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 @@ void listener_accept(int fd) */ 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 @@ void listener_accept(int fd) 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 @@ void listener_accept(int fd) 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 @@ static int bind_parse_maxconn(char **args, int cur_arg, struct proxy *px, struct } 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 dc5bdeaf8..743bce88e 100644 --- a/src/peers.c +++ b/src/peers.c @@ -2551,14 +2551,11 @@ static struct task *process_peer_sync(struct task * task, void *context, unsigne 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 78e099ee9..d3c069882 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -1884,7 +1884,8 @@ static int cli_parse_set_maxconn_frontend(char **args, char *payload, struct app 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 a7c12e120..26b1450e8 100644 --- a/src/stats.c +++ b/src/stats.c @@ -1472,7 +1472,7 @@ int stats_fill_li_stats(struct proxy *px, struct listener *l, int flags, 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);