From: Amaury Denoyelle Date: Tue, 24 Aug 2021 14:11:18 +0000 (+0200) Subject: MEDIUM: mux-quic: implement ring buffer on stream tx X-Git-Tag: v2.5-dev8~57 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f52151d83e6e8d7f7274430463ffdf81a06ca17c;p=thirdparty%2Fhaproxy.git MEDIUM: mux-quic: implement ring buffer on stream tx --- diff --git a/include/haproxy/mux_quic-t.h b/include/haproxy/mux_quic-t.h index e704f167e6..4ca53688f7 100644 --- a/include/haproxy/mux_quic-t.h +++ b/include/haproxy/mux_quic-t.h @@ -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 */ diff --git a/src/h3.c b/src/h3.c index ed0575014e..f961ab1f09 100644 --- 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 . * 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. diff --git a/src/mux_quic.c b/src/mux_quic.c index 1cd775fbdc..41a6ce1e14 100644 --- a/src/mux_quic.c +++ b/src/mux_quic.c @@ -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);