]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: mux-quic: free RX buf if empty
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 18 May 2022 14:19:47 +0000 (16:19 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 18 May 2022 14:25:07 +0000 (16:25 +0200)
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

index 6cc7756d88729063175b4d7eb51f148202fcbcc8..5205f0a18460f7880f5ee898584f07819175fc1e 100644 (file)
@@ -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);