From: Christopher Faulet Date: Wed, 1 Jul 2020 13:12:43 +0000 (+0200) Subject: MINOR: connection: Set new connection as private on reuse never X-Git-Tag: v2.3-dev1~30 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c64badd573310f88339369ed0902dd1803e6cdc0;p=thirdparty%2Fhaproxy.git MINOR: connection: Set new connection as private on reuse never When a new connection is created, it may immediatly be set as private if http-reuse never is configured for the backend. There is no reason to wait the call to mux->detach() to do so. --- diff --git a/src/backend.c b/src/backend.c index 3f6e7daa27..e94fc1faf4 100644 --- a/src/backend.c +++ b/src/backend.c @@ -1401,6 +1401,9 @@ int connect_server(struct stream *s) if (srv_conn) srv_conn->target = s->target; srv_cs = NULL; + + if ((s->be->options & PR_O_REUSE_MASK) == PR_O_REUSE_NEVR) + conn->flags |= CO_FL_PRIVATE; } if (srv_conn && srv && was_unused) { diff --git a/src/mux_fcgi.c b/src/mux_fcgi.c index 76e93e4344..7cd5612195 100644 --- a/src/mux_fcgi.c +++ b/src/mux_fcgi.c @@ -3540,9 +3540,6 @@ static void fcgi_detach(struct conn_stream *cs) if (!(fconn->conn->flags & (CO_FL_ERROR|CO_FL_SOCK_RD_SH|CO_FL_SOCK_WR_SH)) && (fconn->flags & FCGI_CF_KEEP_CONN)) { - /* Never ever allow to reuse a connection from a non-reuse backend */ - if ((fconn->proxy->options & PR_O_REUSE_MASK) == PR_O_REUSE_NEVR) - fconn->conn->flags |= CO_FL_PRIVATE; if (fconn->conn->flags & CO_FL_PRIVATE) { if (!fconn->conn->owner) { fconn->conn->owner = sess; diff --git a/src/mux_h1.c b/src/mux_h1.c index 80a7b7db51..6f594410d9 100644 --- a/src/mux_h1.c +++ b/src/mux_h1.c @@ -2453,10 +2453,6 @@ static void h1_detach(struct conn_stream *cs) goto release; } - /* Never ever allow to reuse a connection from a non-reuse backend */ - if ((h1c->px->options & PR_O_REUSE_MASK) == PR_O_REUSE_NEVR) - h1c->conn->flags |= CO_FL_PRIVATE; - if (!(h1c->conn->owner) && (h1c->conn->flags & CO_FL_PRIVATE)) { h1c->conn->owner = sess; if (!session_add_conn(sess, h1c->conn, h1c->conn->target)) { diff --git a/src/mux_h2.c b/src/mux_h2.c index fc35c66a27..22c67b02a7 100644 --- a/src/mux_h2.c +++ b/src/mux_h2.c @@ -3942,9 +3942,6 @@ static void h2_detach(struct conn_stream *cs) if (h2c->flags & H2_CF_IS_BACK) { if (!(h2c->conn->flags & (CO_FL_ERROR | CO_FL_SOCK_RD_SH | CO_FL_SOCK_WR_SH))) { - /* Never ever allow to reuse a connection from a non-reuse backend */ - if ((h2c->proxy->options & PR_O_REUSE_MASK) == PR_O_REUSE_NEVR) - h2c->conn->flags |= CO_FL_PRIVATE; if (h2c->conn->flags & CO_FL_PRIVATE) { if (!h2c->conn->owner) { h2c->conn->owner = sess;