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.
This commit is contained in:
Willy Tarreau 2023-01-12 18:52:23 +01:00
parent ee378165fb
commit 882f2485a1
4 changed files with 17 additions and 12 deletions

View File

@ -200,6 +200,7 @@ struct bind_conf {
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 @@ struct listener {
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 */

View File

@ -714,6 +714,9 @@ int cfg_parse_peers(const char *file, int linenum, char **args, int kwm)
err_code |= ERR_FATAL;
goto out;
}
bind_conf->maxaccept = 1;
if (*args[0] == 'b') {
struct listener *l;
@ -743,7 +746,6 @@ int cfg_parse_peers(const char *file, int linenum, char **args, int kwm)
* 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 @@ int cfg_parse_peers(const char *file, int linenum, char **args, int kwm)
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 @@ int cfg_parse_peers(const char *file, int linenum, char **args, int kwm)
* 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 @@ init_proxies_list_stage2:
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 @@ init_proxies_list_stage2:
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;

View File

@ -842,10 +842,10 @@ void listener_accept(struct listener *l)
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);

View File

@ -3525,7 +3525,7 @@ void syslog_fd_handler(int fd)
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 @@ static void syslog_io_handler(struct appctx *appctx)
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 @@ int cfg_parse_log_forward(const char *file, int linenum, char **args, int kwm)
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 @@ int cfg_parse_log_forward(const char *file, int linenum, char **args, int kwm)
}
}
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 @@ int cfg_parse_log_forward(const char *file, int linenum, char **args, int kwm)
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 @@ int cfg_parse_log_forward(const char *file, int linenum, char **args, int kwm)
}
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++;
}