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.
This commit is contained in:
Amaury Denoyelle 2023-03-09 10:14:28 +01:00
parent b47310d883
commit e2213df9fe

View File

@ -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;