From 37c2e4a65a3884c9928a7370397b1c03367db8f0 Mon Sep 17 00:00:00 2001 From: Amaury Denoyelle Date: Mon, 16 May 2022 13:54:59 +0200 Subject: [PATCH] MEDIUM: mux-quic: implement recv on io-cb Previously, qc_io_cb() of mux-quic only dealt with TX. Add support for RX in it. This is done through a new function qc_recv(qcc). It loops over all QCS instances and call qcc_decode_qcs(qcs). This has no impact from the quic-conn layer as qcc_decode_qcs(qcs) is called directly. However, this allows to have a resume point when demux is blocked on the upper layer HTX full buffer. Note that for the moment, only RX for bidirectional streams is managed in qc_io_cb(). Unidirectional streams use their own mechanism for both TX/RX. It should be unified in the near future in a refactoring. --- src/mux_quic.c | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/src/mux_quic.c b/src/mux_quic.c index f5de55105..bd671af9d 100644 --- a/src/mux_quic.c +++ b/src/mux_quic.c @@ -1034,6 +1034,40 @@ static int qc_send(struct qcc *qcc) return total; } +/* Proceed on receiving. Loop through all streams from and use decode_qcs + * operation. + * + * Returns 0 on success else non-zero. + */ +static int qc_recv(struct qcc *qcc) +{ + struct eb64_node *node; + struct qcs *qcs; + + node = eb64_first(&qcc->streams_by_id); + while (node) { + qcs = eb64_entry(node, struct qcs, by_id); + + /* TODO unidirectional streams have their own mechanism for Rx. + * This should be unified. + */ + if (quic_stream_is_uni(qcs->id)) { + node = eb64_next(node); + continue; + } + + if (!ncb_data(&qcs->rx.ncbuf, 0) || (qcs->flags & QC_SF_DEM_FULL)) { + node = eb64_next(node); + continue; + } + + qcc_decode_qcs(qcc, qcs); + node = eb64_next(node); + } + + return 0; +} + /* Release all streams that are already marked as detached. This is only done * if their TX buffers are empty or if a CONNECTION_CLOSE has been received. * @@ -1086,6 +1120,8 @@ static struct task *qc_io_cb(struct task *t, void *ctx, unsigned int status) } } + qc_recv(qcc); + TRACE_LEAVE(QMUX_EV_QCC_WAKE); return NULL; @@ -1335,9 +1371,6 @@ static size_t qc_rcv_buf(struct conn_stream *cs, struct buffer *buf, } } - /* TODO QUIC MUX iocb does not treat RX : following wake-up is thus - * useless for the moment. This may causes freezing transfer on POST. - */ if (ret) { qcs->flags &= ~QC_SF_DEM_FULL; tasklet_wakeup(qcs->qcc->wait_event.tasklet);