]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: mux-quic: define flag for last received frame
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 28 Feb 2022 10:36:57 +0000 (11:36 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 1 Mar 2022 09:52:31 +0000 (10:52 +0100)
This flag is set when the STREAM frame with FIN set has been received on
a qcs instance. For now, this is only used as a BUG_ON guard to prevent
against multiple frames with FIN set. It will also be useful when
reorganize the RX path and move some of its code in the mux.

include/haproxy/mux_quic-t.h
src/xprt_quic.c

index 88485ef6ad63d231dcaf545ff18280f97651045f..b1f37564bc6eae01b6f3482ca9185406b3d77bea 100644 (file)
@@ -63,9 +63,10 @@ struct qcc {
 };
 
 #define QC_SF_NONE              0x00000000
-#define QC_SF_FIN_STREAM        0x00000001  // FIN bit must be set for last frame of the stream
-#define QC_SF_BLK_MROOM         0x00000002  // app layer is blocked waiting for room in the qcs.tx.buf
-#define QC_SF_DETACH            0x00000004  // cs is detached but there is remaining data to send
+#define QC_SF_FIN_RECV          0x00000001  // last frame received for this stream
+#define QC_SF_FIN_STREAM        0x00000002  // FIN bit must be set for last frame of the stream
+#define QC_SF_BLK_MROOM         0x00000004  // app layer is blocked waiting for room in the qcs.tx.buf
+#define QC_SF_DETACH            0x00000008  // cs is detached but there is remaining data to send
 
 struct qcs {
        struct qcc *qcc;
index 06bcbf6830f414511a27b2d247a9bf17c964a22e..aaace9c124c680428fa17c56cbc053cca78fbadb 100644 (file)
@@ -2079,7 +2079,6 @@ static int qc_handle_bidi_strm_frm(struct quic_rx_packet *pkt,
        struct qcs *strm;
        struct eb64_node *strm_node;
        struct quic_rx_strm_frm *frm;
-       char fin = 0;
 
        strm_node = qcc_get_qcs(qc->qcc, strm_frm->id);
        if (!strm_node) {
@@ -2104,6 +2103,8 @@ static int qc_handle_bidi_strm_frm(struct quic_rx_packet *pkt,
                strm_frm->data += diff;
        }
 
+       BUG_ON(strm->flags & QC_SF_FIN_RECV);
+
        total = 0;
        if (strm_frm->offset.key == strm->rx.offset) {
                int ret;
@@ -2118,8 +2119,10 @@ static int qc_handle_bidi_strm_frm(struct quic_rx_packet *pkt,
 
        total += qc_treat_rx_strm_frms(strm);
        /* FIN is set only if all data were copied. */
-       fin = strm_frm->fin && !strm_frm->len;
-       if (total && qc->qcc->app_ops->decode_qcs(strm, fin, qc->qcc->ctx) < 0) {
+       if (strm_frm->fin && !strm_frm->len)
+               strm->flags |= QC_SF_FIN_RECV;
+
+       if (total && qc->qcc->app_ops->decode_qcs(strm, strm->flags & QC_SF_FIN_RECV, qc->qcc->ctx) < 0) {
                TRACE_PROTO("Decoding error", QUIC_EV_CONN_PSTRM, qc);
                return 0;
        }