From 2c52a2b9ee472574d59c97427e5149df1e5eb496 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Sun, 8 Oct 2017 11:00:17 +0200 Subject: [PATCH] MEDIUM: connection: make mux->detach() release the connection For H2, only the mux's timeout or other conditions might cause a release of the mux and the connection, no stream should be allowed to kill such a shared connection. So a stream will only detach using cs_destroy() which will call mux->detach() then free the cs. For now it's only handled by mux_pt. The goal is that the data layer never has to care about the connection, which will have to be released depending on the mux's mood. --- include/proto/connection.h | 7 +------ src/mux_pt.c | 9 +++++++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/proto/connection.h b/include/proto/connection.h index cae5dc3435..4c952e0346 100644 --- a/include/proto/connection.h +++ b/include/proto/connection.h @@ -694,12 +694,7 @@ static inline void conn_free(struct connection *conn) /* Release a conn_stream, and kill the connection if it was the last one */ static inline void cs_destroy(struct conn_stream *cs) { - struct connection *conn = cs->conn; - - LIST_DEL(&conn->list); - conn_stop_tracking(conn); - conn_full_close(conn); - conn_free(conn); + cs->conn->mux->detach(cs); cs_free(cs); } diff --git a/src/mux_pt.c b/src/mux_pt.c index e9a7d2f8cd..8a8aec0889 100644 --- a/src/mux_pt.c +++ b/src/mux_pt.c @@ -113,11 +113,16 @@ static struct conn_stream *mux_pt_attach(struct connection *conn) } /* - * Detach the stream from the connection - * (Used for outgoing connections) + * Detach the stream from the connection and possibly release the connection. */ static void mux_pt_detach(struct conn_stream *cs) { + struct connection *conn = cs->conn; + + LIST_DEL(&conn->list); + conn_stop_tracking(conn); + conn_full_close(conn); + conn_free(conn); } static void mux_pt_shutr(struct conn_stream *cs, enum cs_shr_mode mode) -- 2.39.5