]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: quic: liberate the TX stream buffer after ACK processing
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 24 Feb 2022 09:56:33 +0000 (10:56 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Fri, 25 Feb 2022 14:06:17 +0000 (15:06 +0100)
The sending buffer of each stream is cleared when processing ACKs
corresponding to STREAM emitted frames. If the buffer is empty, free it
and offer it as with other dynamic buffers usage.

This should reduce memory consumption as before an opened stream
confiscate a buffer during its whole lifetime even if there is no more
data to transmit.

src/xprt_quic.c

index a6eda370b54a37b1f3e2250780774f11334bcb3c..3e63187b73e70f9b97caf07a9235d2ce3966cbfc 100644 (file)
@@ -1405,6 +1405,11 @@ static int qcs_try_to_consume(struct qcs *qcs)
                        qcs->tx.ack_offset += diff;
                        b_del(strm->buf, diff);
                        ret = 1;
+
+                       if (!b_data(strm->buf)) {
+                               b_free(strm->buf);
+                               offer_buffers(NULL, 1);
+                       }
                }
 
                frm_node = eb64_next(frm_node);
@@ -1435,6 +1440,11 @@ static inline void qc_treat_acked_tx_frm(struct quic_conn *qc,
                                qcs->tx.ack_offset += diff;
                                b_del(strm->buf, diff);
                                stream_acked = 1;
+
+                               if (!b_data(strm->buf)) {
+                                       b_free(strm->buf);
+                                       offer_buffers(NULL, 1);
+                               }
                        }
 
                        LIST_DELETE(&frm->list);