From: Olivier Houchard Date: Fri, 30 Nov 2018 16:31:52 +0000 (+0100) Subject: MEDIUM: session: Steal owner-less connections on end of transaction. X-Git-Tag: v1.9-dev9~97 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=985f139aa23f937c94efcdeaf924c80edfade4df;p=thirdparty%2Fhaproxy.git MEDIUM: session: Steal owner-less connections on end of transaction. When a transaction ends, if we want to do keepalive, and the connection we used didn't have an owner, attach the connection to the session, so that we don't have to destroy it, and we can reuse it later. --- diff --git a/src/proto_http.c b/src/proto_http.c index eb898a771a..7c658d92b2 100644 --- a/src/proto_http.c +++ b/src/proto_http.c @@ -70,6 +70,7 @@ #include #include #include +#include #include #include #include @@ -3748,10 +3749,6 @@ void http_end_txn_clean_session(struct stream *s) /* unless we're doing keep-alive, we want to quickly close the connection * to the server. - * XXX cognet: If the connection doesn't have a owner then it may not - * be referenced anywhere, just kill it now, even if it could be reused. - * To be revisited later when revisited later when we handle connection - * pools properly. */ if (((s->txn->flags & TX_CON_WANT_MSK) != TX_CON_WANT_KAL) || !si_conn_ready(&s->si[1]) || !srv_conn->owner) { @@ -3842,8 +3839,12 @@ void http_end_txn_clean_session(struct stream *s) * We then can call si_release_endpoint() to destroy the conn_stream */ if (((s->txn->flags & TX_CON_WANT_MSK) != TX_CON_WANT_KAL) || - !si_conn_ready(&s->si[1]) || !srv_conn->owner) + !si_conn_ready(&s->si[1])) srv_conn = NULL; + else if (!srv_conn->owner) { + srv_conn->owner = s->sess; + session_add_conn(s->sess, srv_conn, s->target); + } si_release_endpoint(&s->si[1]); s->si[1].state = s->si[1].prev_state = SI_ST_INI;