]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: mux-quic: implement ring buffer on stream tx
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 24 Aug 2021 14:11:18 +0000 (16:11 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 23 Sep 2021 13:27:25 +0000 (15:27 +0200)
include/haproxy/mux_quic-t.h
src/h3.c
src/mux_quic.c

index e704f167e63b6bc24e4ea92eca46ee826b1530cd..4ca53688f7febffc186ad71cec6416fd3cfaee25 100644 (file)
@@ -199,6 +199,7 @@ struct qcs {
                uint64_t offset;   /* the current offset of data to send */
                uint64_t bytes;    /* number of bytes sent */
                struct buffer buf; /* transmit buffer, always valid (buf_empty or real buffer) */
+               struct buffer mbuf[QCC_MBUF_CNT];
        } tx;
        struct wait_event *subs;  /* recv wait_event the conn_stream associated is waiting on (via qc_subscribe) */
        struct list list; /* To be used when adding in qcc->send_list or qcc->fctl_lsit */
index ed0575014e4aa7838fadd76bd8caeff61fbe678f..f961ab1f090153a877e1ed768c967069a8a212e6 100644 (file)
--- a/src/h3.c
+++ b/src/h3.c
@@ -414,6 +414,28 @@ static int h3_control_send(struct h3_uqs *h3_uqs, void *ctx)
        return ret;
 }
 
+/* Return next empty buffer of mux.
+ * TODO to optimize memory consumption, a non-full buffer should be used before
+ * allocating a new one.
+ * TODO put this in mux ??
+ */
+static struct buffer *get_mux_next_tx_buf(struct qcs *qcs)
+{
+       struct buffer *buf = br_tail(qcs->tx.mbuf);
+
+       if (b_data(buf))
+               buf = br_tail_add(qcs->tx.mbuf);
+
+       if (!b_size(buf))
+               qc_get_buf(qcs->qcc, buf);
+
+       if (!buf)
+               ABORT_NOW();
+
+       return buf;
+
+}
+
 /* Finalize the initialization of remotely initiated uni-stream <qcs>.
  * Return 1 if succeeded, 0 if not. In this latter case, set the ->err h3 error
  * to inform the QUIC mux layer of the encountered error.
index 1cd775fbdc0627c2181b24530a535aef66243b3b..41a6ce1e140c163827243ced53b0c30562fe65ee 100644 (file)
@@ -982,6 +982,8 @@ struct qcs *bidi_qcs_new(struct qcc *qcc, uint64_t id)
        qcs->tx.st       = QC_TX_SS_IDLE;
        qcs->tx.bytes    = qcs->tx.offset = 0;
        qcs->tx.max_data = qcc->strms[qcs_type].tx.max_data;
+       qcs->tx.buf = BUF_NULL;
+       br_init(qcs->tx.mbuf, sizeof(qcs->tx.mbuf) / sizeof(qcs->tx.mbuf[0]));
 
        eb64_insert(&qcc->streams_by_id, &qcs->by_id);
        qcc->strms[qcs_type].nb_streams++;
@@ -1045,6 +1047,7 @@ struct qcs *luqs_new(struct qcc *qcc)
        qcs->tx.max_data = qcc->strms[qcs_type].tx.max_data;
        qcs->tx.offset = qcs->tx.bytes = 0;
        qcs->tx.buf = BUF_NULL;
+       br_init(qcs->tx.mbuf, sizeof(qcs->tx.mbuf) / sizeof(qcs->tx.mbuf[0]));
 
        qcs->subs = NULL;
        LIST_INIT(&qcs->list);
@@ -1085,6 +1088,7 @@ struct qcs *ruqs_new(struct qcc *qcc, uint64_t id)
        qcs->rx.max_data = qcc->strms[qcs_type].rx.max_data;
        qcs->rx.offset = qcs->rx.bytes = 0;
        qcs->rx.buf = BUF_NULL;
+       br_init(qcs->tx.mbuf, sizeof(qcs->tx.mbuf) / sizeof(qcs->tx.mbuf[0]));
 
        qcs->subs = NULL;
        LIST_INIT(&qcs->list);