From: Amaury Denoyelle Date: Wed, 18 May 2022 14:19:47 +0000 (+0200) Subject: MINOR: mux-quic: free RX buf if empty X-Git-Tag: v2.6-dev11~52 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8b87b15c22ffa04b27cc49c978061956519655d1;p=thirdparty%2Fhaproxy.git 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(). --- diff --git a/src/mux_quic.c b/src/mux_quic.c index 6cc7756d88..5205f0a184 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);