From: Christopher Faulet Date: Fri, 23 Nov 2018 22:10:39 +0000 (+0100) Subject: MEDIUM: mux-h1: Add keep-alive outgoing connections in connections list X-Git-Tag: v1.9-dev9~76 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9400a3924d24d4c72cb11ca40efe9b045880ddd7;p=thirdparty%2Fhaproxy.git MEDIUM: mux-h1: Add keep-alive outgoing connections in connections list With the legacy representation, keep-alive outgoing connections are added in private/idle/safe connections list when the transaction is cleaned up. But this stage does not exist with the HTX representaion because a new stream, and therefore a new transaction, is created for each request. So it is now handled when the stream is detached from the connection. --- diff --git a/src/mux_h1.c b/src/mux_h1.c index b70afa7ae6..4d9db7fba4 100644 --- a/src/mux_h1.c +++ b/src/mux_h1.c @@ -1633,6 +1633,26 @@ static void h1_detach(struct conn_stream *cs) h1c = h1s->h1c; h1s->cs = NULL; + if (conn_is_back(h1c->conn) && (h1s->flags & H1S_F_WANT_KAL)) { + /* Never ever allow to reuse a connection from a non-reuse backend */ + if (h1c->conn && (h1c->px->options & PR_O_REUSE_MASK) == PR_O_REUSE_NEVR) + h1c->conn->flags |= CO_FL_PRIVATE; + + /* we're in keep-alive with an idle connection, monitor it if not already done */ + if (h1c->conn && LIST_ISEMPTY(&h1c->conn->list)) { + struct server *srv = objt_server(h1c->conn->target); + + if (srv) { + if (h1c->conn->flags & CO_FL_PRIVATE) + LIST_ADD(&srv->priv_conns[tid], &h1c->conn->list); + else if (h1s->flags & H1S_F_NOT_FIRST) + LIST_ADD(&srv->safe_conns[tid], &h1c->conn->list); + else + LIST_ADD(&srv->idle_conns[tid], &h1c->conn->list); + } + } + } + h1s_destroy(h1s); /* We don't want to close right now unless the connection is in error */