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 945fd6d..c674323 100644
--- a/src/mux_quic.c
+++ b/src/mux_quic.c
@@ -31,6 +31,9 @@
{
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 @@
{
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;