diff --git a/doc/configuration.txt b/doc/configuration.txt index 5f8d47323..25683f484 100644 --- a/doc/configuration.txt +++ b/doc/configuration.txt @@ -15332,6 +15332,11 @@ namespace a namespace different from the default one. Please refer to your operating system's documentation to find more details about network namespaces. +nbconn + This setting is only valid for listener instances which uses reverse HTTP. + This will define the count of connections which will be mounted in parallel. + If not specified, a default value of 1 is used. + nice Sets the 'niceness' of connections initiated from the socket. Value must be in the range -1024..1024 inclusive, and defaults to zero. Positive values diff --git a/include/haproxy/listener-t.h b/include/haproxy/listener-t.h index 8f7cbb13e..bb4313176 100644 --- a/include/haproxy/listener-t.h +++ b/include/haproxy/listener-t.h @@ -209,6 +209,7 @@ struct bind_conf { char *file; /* file where the section appears */ int line; /* line where the section appears */ char *reverse_srvname; /* name of server when using "rev@" address */ + int reverse_nbconn; /* count of connections to initiate in parallel */ __decl_thread(HA_RWLOCK_T sni_lock); /* lock the SNI trees during add/del operations */ struct thread_set thread_set; /* entire set of the allowed threads (0=no restriction) */ struct rx_settings settings; /* all the settings needed for the listening socket */ diff --git a/src/listener.c b/src/listener.c index da483702e..f812d9fad 100644 --- a/src/listener.c +++ b/src/listener.c @@ -2241,6 +2241,33 @@ static int bind_parse_name(char **args, int cur_arg, struct proxy *px, struct bi return 0; } +/* parse the "nbconn" bind keyword */ +static int bind_parse_nbconn(char **args, int cur_arg, struct proxy *px, struct bind_conf *conf, char **err) +{ + int val; + const struct listener *l; + + l = LIST_NEXT(&conf->listeners, struct listener *, by_bind); + if (l->rx.addr.ss_family != AF_CUST_REV_SRV) { + memprintf(err, "'%s' : only valid for reverse HTTP listeners.", args[cur_arg]); + return ERR_ALERT | ERR_FATAL; + } + + if (!*args[cur_arg + 1]) { + memprintf(err, "'%s' : missing value.", args[cur_arg]); + return ERR_ALERT | ERR_FATAL; + } + + val = atol(args[cur_arg + 1]); + if (val <= 0) { + memprintf(err, "'%s' : invalid value %d, must be > 0.", args[cur_arg], val); + return ERR_ALERT | ERR_FATAL; + } + + conf->reverse_nbconn = val; + return 0; +} + /* parse the "nice" bind keyword */ static int bind_parse_nice(char **args, int cur_arg, struct proxy *px, struct bind_conf *conf, char **err) { @@ -2402,6 +2429,7 @@ static struct bind_kw_list bind_kws = { "ALL", { }, { { "id", bind_parse_id, 1 }, /* set id of listening socket */ { "maxconn", bind_parse_maxconn, 1 }, /* set maxconn of listening socket */ { "name", bind_parse_name, 1 }, /* set name of listening socket */ + { "nbconn", bind_parse_nbconn, 1 }, /* set number of connection on active preconnect */ { "nice", bind_parse_nice, 1 }, /* set nice of listening socket */ { "process", bind_parse_process, 1 }, /* set list of allowed process for this socket */ { "proto", bind_parse_proto, 1 }, /* set the proto to use for all incoming connections */ diff --git a/src/proto_reverse_connect.c b/src/proto_reverse_connect.c index ef9e40f46..293c13418 100644 --- a/src/proto_reverse_connect.c +++ b/src/proto_reverse_connect.c @@ -204,9 +204,12 @@ int rev_bind_listener(struct listener *listener, char *errmsg, int errlen) listener->rx.reverse_connect.task = task; listener->rx.reverse_connect.state = LI_PRECONN_ST_STOP; - /* Set a default maxconn to 1. This ensures listener is properly - * reenable each time we fall back below it on connection error. + /* Set maxconn which is defined via the special kw nbconn for reverse + * connect. Use a default value of 1 if not set. This guarantees that + * listener will be automatically reenable each time it fell back below + * it due to a connection error. */ + listener->bind_conf->maxconn = listener->bind_conf->reverse_nbconn; if (!listener->bind_conf->maxconn) listener->bind_conf->maxconn = 1; @@ -286,7 +289,7 @@ void rev_disable_listener(struct listener *l) { if (l->rx.reverse_connect.state < LI_PRECONN_ST_FULL) { send_log(l->bind_conf->frontend, LOG_INFO, - "preconnect %s::%s: Reaching maxconn %d.\n", + "preconnect %s::%s: Running with nbconn %d reached.\n", l->bind_conf->frontend->id, l->bind_conf->reverse_srvname, l->bind_conf->maxconn); l->rx.reverse_connect.state = LI_PRECONN_ST_FULL;