From: Amaury Denoyelle Date: Thu, 9 Mar 2023 09:14:28 +0000 (+0100) Subject: MINOR: mux-quic: ensure CONNECTION_CLOSE is scheduled once per conn X-Git-Tag: v2.8-dev6~11 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e2213df9fe5a84288a952bd685a0cafc3d1f6b3c;p=thirdparty%2Fhaproxy.git MINOR: mux-quic: ensure CONNECTION_CLOSE is scheduled once per conn Add BUG_ON() statements to ensure qcc_emit_cc()/qcc_emit_cc_app() is not called more than one time for each connection. This should improve code resilience of MUX-QUIC and H3 and it will ensure that a scheduled CONNECTION_CLOSE is not overwritten by another one with a different error code. This commit relies on the previous one to ensure all QUIC operations are not conducted as soon as a CONNECTION_CLOSE has been prepared : commit d7fbf458f8a4c5b09cbf0da0208fbad70caaca33 MINOR: mux-quic: interrupt most operations if CONNECTION_CLOSE scheduled This should be backported up to 2.7. --- diff --git a/src/mux_quic.c b/src/mux_quic.c index 945fd6d5f0..c67432391d 100644 --- a/src/mux_quic.c +++ b/src/mux_quic.c @@ -31,6 +31,9 @@ static void qcc_emit_cc(struct qcc *qcc, int err) { TRACE_ENTER(QMUX_EV_QCC_END, qcc->conn); + /* This function must not be called multiple times. */ + BUG_ON(qcc->flags & QC_CF_CC_EMIT); + TRACE_STATE("set CONNECTION_CLOSE on quic-conn", QMUX_EV_QCC_WAKE, qcc->conn); quic_set_connection_close(qcc->conn->handle.qc, quic_err_transport(err)); qcc->flags |= QC_CF_CC_EMIT; @@ -832,6 +835,9 @@ void qcc_emit_cc_app(struct qcc *qcc, int err, int immediate) { TRACE_ENTER(QMUX_EV_QCC_END, qcc->conn); + /* This function must not be called multiple times after immediate is set. */ + BUG_ON(qcc->flags & QC_CF_CC_EMIT); + if (immediate) { quic_set_connection_close(qcc->conn->handle.qc, quic_err_app(err)); qcc->flags |= QC_CF_CC_EMIT;