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 6cc7756..5205f0a 100644
--- a/src/mux_quic.c
+++ b/src/mux_quic.c
@@ -296,13 +296,17 @@
{
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);