From 4e61096e306ee9da46fb2db4dcef784587323272 Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Thu, 14 Apr 2022 11:23:50 +0200 Subject: [PATCH] MINOR: muxes: Don't handle proto upgrade for muxes not supporting it Several muxes (h2, fcgi, quic) don't support the protocol upgrade. For these muxes, there is no reason to have code to support it. Thus in the destroy callback, there is now a BUG_ON() and the release function is simplified because the connection is always owned by the mux.. --- src/mux_fcgi.c | 8 ++++---- src/mux_h2.c | 8 ++++---- src/mux_quic.c | 4 +--- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/mux_fcgi.c b/src/mux_fcgi.c index cdb118c3a..cfe39dd83 100644 --- a/src/mux_fcgi.c +++ b/src/mux_fcgi.c @@ -845,9 +845,7 @@ static void fcgi_release(struct fcgi_conn *fconn) TRACE_POINT(FCGI_EV_FCONN_END); if (fconn) { - /* The connection must be attached to this mux to be released */ - if (fconn->conn && fconn->conn->ctx == fconn) - conn = fconn->conn; + conn = fconn->conn; TRACE_DEVEL("freeing fconn", FCGI_EV_FCONN_END, conn); @@ -3576,8 +3574,10 @@ static void fcgi_destroy(void *ctx) struct fcgi_conn *fconn = ctx; TRACE_POINT(FCGI_EV_FCONN_END, fconn->conn); - if (eb_is_empty(&fconn->streams_by_id) || fconn->conn->ctx != fconn) + if (eb_is_empty(&fconn->streams_by_id)) { + BUG_ON(fconn->conn->ctx != fconn); fcgi_release(fconn); + } } /* diff --git a/src/mux_h2.c b/src/mux_h2.c index d73e0cf44..000f23124 100644 --- a/src/mux_h2.c +++ b/src/mux_h2.c @@ -1166,9 +1166,7 @@ static void h2_release(struct h2c *h2c) TRACE_ENTER(H2_EV_H2C_END); if (h2c) { - /* The connection must be aattached to this mux to be released */ - if (h2c->conn && h2c->conn->ctx == h2c) - conn = h2c->conn; + conn = h2c->conn; TRACE_DEVEL("freeing h2c", H2_EV_H2C_END, conn); hpack_dht_free(h2c->ddht); @@ -4350,8 +4348,10 @@ static void h2_destroy(void *ctx) struct h2c *h2c = ctx; TRACE_ENTER(H2_EV_H2C_END, h2c->conn); - if (eb_is_empty(&h2c->streams_by_id) || h2c->conn->ctx != h2c) + if (eb_is_empty(&h2c->streams_by_id)) { + BUG_ON(h2c->conn->ctx != h2c); h2_release(h2c); + } TRACE_LEAVE(H2_EV_H2C_END); } diff --git a/src/mux_quic.c b/src/mux_quic.c index 2051bff10..aea649100 100644 --- a/src/mux_quic.c +++ b/src/mux_quic.c @@ -502,9 +502,7 @@ static void qc_release(struct qcc *qcc) if (qcc) { struct eb64_node *node; - /* The connection must be aattached to this mux to be released */ - if (qcc->conn && qcc->conn->ctx == qcc) - conn = qcc->conn; + conn = qcc->conn; TRACE_DEVEL("freeing qcc", QMUX_EV_QCC_END, conn);