diff --git a/include/haproxy/mux_quic-t.h b/include/haproxy/mux_quic-t.h index 43ea53044..9602cc4c0 100644 --- a/include/haproxy/mux_quic-t.h +++ b/include/haproxy/mux_quic-t.h @@ -117,6 +117,7 @@ struct qcc { #define QC_SF_DEM_FULL 0x00000020 /* demux blocked on request channel buffer full */ #define QC_SF_READ_ABORTED 0x00000040 /* stream rejected by app layer */ #define QC_SF_TO_RESET 0x00000080 /* a RESET_STREAM must be sent */ +#define QC_SF_HREQ_RECV 0x00000100 /* a full HTTP request has been received */ /* Maximum size of stream Rx buffer. */ #define QC_S_RX_BUF_SZ (global.tune.bufsize - NCB_RESERVED_SZ) diff --git a/include/haproxy/mux_quic.h b/include/haproxy/mux_quic.h index 699007e93..892ae9130 100644 --- a/include/haproxy/mux_quic.h +++ b/include/haproxy/mux_quic.h @@ -92,6 +92,11 @@ static inline struct stconn *qc_attach_sc(struct qcs *qcs, struct buffer *buf) if (!sc_new_from_endp(qcs->sd, sess, buf)) return NULL; + /* QC_SF_HREQ_RECV must be set once for a stream. Else, nb_hreq counter + * will be incorrect for the connection. + */ + BUG_ON_HOT(qcs->flags & QC_SF_HREQ_RECV); + qcs->flags |= QC_SF_HREQ_RECV; ++qcc->nb_sc; ++qcc->nb_hreq; diff --git a/src/mux_quic.c b/src/mux_quic.c index 4a6c1a884..38c863dee 100644 --- a/src/mux_quic.c +++ b/src/mux_quic.c @@ -414,7 +414,9 @@ static void qcs_close_local(struct qcs *qcs) if (quic_stream_is_bidi(qcs->id)) { qcs->st = (qcs->st == QC_SS_HREM) ? QC_SS_CLO : QC_SS_HLOC; - qcc_rm_hreq(qcs->qcc); + + if (qcs->flags & QC_SF_HREQ_RECV) + qcc_rm_hreq(qcs->qcc); } else { /* Only local uni streams are valid for this operation. */