mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-02-18 03:26:55 +00:00
BUG/MINOR: proto_reverse_connect: set default maxconn
If maxconn is not set for preconnect, it assumes we want to establish a single connection. However, this does not work properly in case the connection is closed after reversal. Listener is not resumed by protocol layer to attempt a new preconnect. To fix this, explicitely set maxconn to 1 in the listener instance if none is defined. This ensures the behavior is consistent. A BUG_ON() has been added to validate we never try to use a listener with a 0 maxconn.
This commit is contained in:
parent
27b2fd2e06
commit
a37abee266
@ -164,6 +164,12 @@ int rev_bind_listener(struct listener *listener, char *errmsg, int errlen)
|
|||||||
task->context = listener;
|
task->context = listener;
|
||||||
listener->rx.reverse_connect.task = task;
|
listener->rx.reverse_connect.task = task;
|
||||||
|
|
||||||
|
/* Set a default maxconn to 1. This ensures listener is properly
|
||||||
|
* reenable each time we fall back below it on connection error.
|
||||||
|
*/
|
||||||
|
if (!listener->bind_conf->maxconn)
|
||||||
|
listener->bind_conf->maxconn = 1;
|
||||||
|
|
||||||
name = strdup(listener->bind_conf->reverse_srvname);
|
name = strdup(listener->bind_conf->reverse_srvname);
|
||||||
if (!name) {
|
if (!name) {
|
||||||
snprintf(errmsg, errlen, "Out of memory.");
|
snprintf(errmsg, errlen, "Out of memory.");
|
||||||
@ -229,8 +235,13 @@ struct connection *rev_accept_conn(struct listener *l, int *status)
|
|||||||
struct connection *conn = l->rx.reverse_connect.pend_conn;
|
struct connection *conn = l->rx.reverse_connect.pend_conn;
|
||||||
|
|
||||||
if (!conn) {
|
if (!conn) {
|
||||||
|
/* Reverse connect listener must have an explicit maxconn set
|
||||||
|
* to ensure it is reenabled on connection error.
|
||||||
|
*/
|
||||||
|
BUG_ON(!l->bind_conf->maxconn);
|
||||||
|
|
||||||
/* Instantiate a new conn if maxconn not yet exceeded. */
|
/* Instantiate a new conn if maxconn not yet exceeded. */
|
||||||
if (l->bind_conf->maxconn && l->nbconn <= l->bind_conf->maxconn) {
|
if (l->nbconn <= l->bind_conf->maxconn) {
|
||||||
l->rx.reverse_connect.pend_conn = new_reverse_conn(l, l->rx.reverse_connect.srv);
|
l->rx.reverse_connect.pend_conn = new_reverse_conn(l, l->rx.reverse_connect.srv);
|
||||||
if (!l->rx.reverse_connect.pend_conn) {
|
if (!l->rx.reverse_connect.pend_conn) {
|
||||||
*status = CO_AC_PAUSE;
|
*status = CO_AC_PAUSE;
|
||||||
|
Loading…
Reference in New Issue
Block a user