From bb6296ce065bf67f82dce2c0f5d37164b68d7bfc Mon Sep 17 00:00:00 2001 From: Amaury Denoyelle Date: Fri, 9 Dec 2022 15:00:17 +0100 Subject: [PATCH] MINOR: mux-quic: do not count stream flow-control if already closed It is unnecessary to increase stream credit once its size is known. Indeed, a peer cannot sent a greater offset than the value advertized. Else, connection will be closed on STREAM reception with FINAL_SIZE_ERROR. This commit is a small optimization and may prevent the emission of unneeded MAX_STREAM_DATA frames on some occasions. It should be backported up to 2.7. --- src/mux_quic.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/mux_quic.c b/src/mux_quic.c index a5e443f7d..e4721fd39 100644 --- a/src/mux_quic.c +++ b/src/mux_quic.c @@ -696,6 +696,10 @@ static void qcs_consume(struct qcs *qcs, uint64_t bytes) qc_free_ncbuf(qcs, buf); qcs->rx.offset += bytes; + /* Not necessary to emit a MAX_STREAM_DATA if all data received. */ + if (qcs->flags & QC_SF_SIZE_KNOWN) + goto conn_fctl; + if (qcs->rx.msd - qcs->rx.offset < qcs->rx.msd_init / 2) { TRACE_DATA("increase stream credit via MAX_STREAM_DATA", QMUX_EV_QCS_RECV, qcc->conn, qcs); frm = pool_zalloc(pool_head_quic_frame); @@ -712,6 +716,7 @@ static void qcs_consume(struct qcs *qcs, uint64_t bytes) tasklet_wakeup(qcc->wait_event.tasklet); } + conn_fctl: qcc->lfctl.offsets_consume += bytes; if (qcc->lfctl.md - qcc->lfctl.offsets_consume < qcc->lfctl.md_init / 2) { TRACE_DATA("increase conn credit via MAX_DATA", QMUX_EV_QCS_RECV, qcc->conn, qcs);