MINOR: listener: move maxaccept from listener to bind_conf
Like for previous values, maxaccept is really per-bind_conf, so let's
move it there. Some frontends (peers, log) set it to 1 so the assignment
was slightly moved.
diff --git a/include/haproxy/listener-t.h b/include/haproxy/listener-t.h
index 4508397..7a6aecc 100644
--- a/include/haproxy/listener-t.h
+++ b/include/haproxy/listener-t.h
@@ -200,6 +200,7 @@
unsigned int analysers; /* bitmap of required protocol analysers */
int maxseg; /* for TCP, advertised MSS */
int tcp_ut; /* for TCP, user timeout */
+ int maxaccept; /* if set, max number of connections accepted at once (-1 when disabled) */
int level; /* stats access level (ACCESS_LVL_*) */
int severity_output; /* default severity output format in cli feedback messages */
struct list listeners; /* list of listeners using this bind config */
@@ -243,7 +244,6 @@
int nbconn; /* current number of connections on this listener */
int maxconn; /* maximum connections allowed on this listener */
unsigned int backlog; /* if set, listen backlog */
- int maxaccept; /* if set, max number of connections accepted at once (-1 when disabled) */
int (*accept)(struct connection *conn); /* upper layer's accept() */
enum obj_type *default_target; /* default target to use for accepted sessions or NULL */
/* cache line boundary */
diff --git a/src/cfgparse.c b/src/cfgparse.c
index cc5c966..ed9c85c 100644
--- a/src/cfgparse.c
+++ b/src/cfgparse.c
@@ -714,6 +714,9 @@
err_code |= ERR_FATAL;
goto out;
}
+
+ bind_conf->maxaccept = 1;
+
if (*args[0] == 'b') {
struct listener *l;
@@ -743,7 +746,6 @@
* Newly allocated listener is at the end of the list
*/
l = LIST_ELEM(bind_conf->listeners.p, typeof(l), by_bind);
- l->maxaccept = 1;
l->accept = session_accept_fd;
l->default_target = curpeers->peers_fe->default_target;
l->options |= LI_O_UNLIMITED; /* don't make the peers subject to global limits */
@@ -946,6 +948,8 @@
goto out;
}
+ bind_conf->maxaccept = 1;
+
if (!LIST_ISEMPTY(&bind_conf->listeners)) {
ha_alert("parsing [%s:%d] : One listener per \"peers\" section is authorized but another is already configured at [%s:%d].\n", file, linenum, bind_conf->file, bind_conf->line);
err_code |= ERR_FATAL;
@@ -967,7 +971,6 @@
* Newly allocated listener is at the end of the list
*/
l = LIST_ELEM(bind_conf->listeners.p, typeof(l), by_bind);
- l->maxaccept = 1;
l->accept = session_accept_fd;
l->default_target = curpeers->peers_fe->default_target;
l->options |= LI_O_UNLIMITED; /* don't make the peers subject to global limits */
@@ -4284,6 +4287,8 @@
bind_conf->xprt->prepare_bind_conf(bind_conf) < 0)
cfgerr++;
bind_conf->analysers |= curproxy->fe_req_ana;
+ if (!bind_conf->maxaccept)
+ bind_conf->maxaccept = global.tune.maxaccept ? global.tune.maxaccept : MAX_ACCEPT;
}
/* adjust this proxy's listeners */
@@ -4308,8 +4313,6 @@
if (curproxy->options & PR_O_TCP_NOLING)
listener->options |= LI_O_NOLINGER;
- if (!listener->maxaccept)
- listener->maxaccept = global.tune.maxaccept ? global.tune.maxaccept : MAX_ACCEPT;
/* listener accept callback */
listener->accept = session_accept_fd;
diff --git a/src/listener.c b/src/listener.c
index 717e878..32a1158 100644
--- a/src/listener.c
+++ b/src/listener.c
@@ -842,10 +842,10 @@
p = l->bind_conf->frontend;
- /* if l->maxaccept is -1, then max_accept is UINT_MAX. It is not really
- * illimited, but it is probably enough.
+ /* if l->bind_conf->maxaccept is -1, then max_accept is UINT_MAX. It is
+ * not really illimited, but it is probably enough.
*/
- max_accept = l->maxaccept ? l->maxaccept : 1;
+ max_accept = l->bind_conf->maxaccept ? l->bind_conf->maxaccept : 1;
if (!(l->options & LI_O_UNLIMITED) && global.sps_lim) {
int max = freq_ctr_remain(&global.sess_per_sec, global.sps_lim, 0);
diff --git a/src/log.c b/src/log.c
index a3475ba..91396a3 100644
--- a/src/log.c
+++ b/src/log.c
@@ -3525,7 +3525,7 @@
if (!fd_recv_ready(fd))
return;
- max_accept = l->maxaccept ? l->maxaccept : 1;
+ max_accept = l->bind_conf->maxaccept ? l->bind_conf->maxaccept : 1;
do {
/* Source address */
@@ -3577,7 +3577,7 @@
char *message;
size_t size;
- max_accept = l->maxaccept ? l->maxaccept : 1;
+ max_accept = l->bind_conf->maxaccept ? l->bind_conf->maxaccept : 1;
while (co_data(sc_oc(sc))) {
char c;
@@ -3810,6 +3810,8 @@
goto out;
}
+ bind_conf->maxaccept = global.tune.maxaccept ? global.tune.maxaccept : MAX_ACCEPT;
+
if (!str2listener(args[1], cfg_log_forward, bind_conf, file, linenum, &errmsg)) {
if (errmsg && *errmsg) {
indent_msg(&errmsg, 2);
@@ -3823,7 +3825,6 @@
}
}
list_for_each_entry(l, &bind_conf->listeners, by_bind) {
- l->maxaccept = global.tune.maxaccept ? global.tune.maxaccept : MAX_ACCEPT;
l->accept = session_accept_fd;
l->default_target = cfg_log_forward->default_target;
global.maxsock++;
@@ -3853,6 +3854,8 @@
goto out;
}
+ bind_conf->maxaccept = global.tune.maxaccept ? global.tune.maxaccept : MAX_ACCEPT;
+
if (!str2receiver(args[1], cfg_log_forward, bind_conf, file, linenum, &errmsg)) {
if (errmsg && *errmsg) {
indent_msg(&errmsg, 2);
@@ -3867,7 +3870,6 @@
}
list_for_each_entry(l, &bind_conf->listeners, by_bind) {
/* the fact that the sockets are of type dgram is guaranteed by str2receiver() */
- l->maxaccept = global.tune.maxaccept ? global.tune.maxaccept : MAX_ACCEPT;
l->rx.iocb = syslog_fd_handler;
global.maxsock++;
}