From 8b87b15c22ffa04b27cc49c978061956519655d1 Mon Sep 17 00:00:00 2001 From: Amaury Denoyelle Date: Wed, 18 May 2022 16:19:47 +0200 Subject: [PATCH] MINOR: mux-quic: free RX buf if empty Release the QCS RX buffer if emptied afer qcs_consume(). This improves memory usage and avoids a QCS to keep an allocated buffer, particularly when no data is received anymore. Buffer is automatically reallocated if needed via qc_get_ncbuf(). --- src/mux_quic.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/mux_quic.c b/src/mux_quic.c index 6cc7756d8..5205f0a18 100644 --- a/src/mux_quic.c +++ b/src/mux_quic.c @@ -296,13 +296,17 @@ void qcs_consume(struct qcs *qcs, uint64_t bytes) { struct qcc *qcc = qcs->qcc; struct quic_frame *frm; + struct ncbuf *buf = &qcs->rx.ncbuf; enum ncb_ret ret; - ret = ncb_advance(&qcs->rx.ncbuf, bytes); + ret = ncb_advance(buf, bytes); if (ret) { ABORT_NOW(); /* should not happens because removal only in data */ } + if (ncb_is_empty(buf)) + qc_free_ncbuf(qcs, buf); + qcs->rx.offset += bytes; if (qcs->rx.msd - qcs->rx.offset < qcs->rx.msd_init / 2) { frm = pool_zalloc(pool_head_quic_frame);