MEDIUM: mux-quic: implement ring buffer on stream tx

This commit is contained in:
Amaury Denoyelle 2021-08-24 16:11:18 +02:00
parent 990435561b
commit f52151d83e
3 changed files with 27 additions and 0 deletions

View File

@ -199,6 +199,7 @@ struct qcs {
uint64_t offset; /* the current offset of data to send */ uint64_t offset; /* the current offset of data to send */
uint64_t bytes; /* number of bytes sent */ uint64_t bytes; /* number of bytes sent */
struct buffer buf; /* transmit buffer, always valid (buf_empty or real buffer) */ struct buffer buf; /* transmit buffer, always valid (buf_empty or real buffer) */
struct buffer mbuf[QCC_MBUF_CNT];
} tx; } tx;
struct wait_event *subs; /* recv wait_event the conn_stream associated is waiting on (via qc_subscribe) */ 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 */ struct list list; /* To be used when adding in qcc->send_list or qcc->fctl_lsit */

View File

@ -414,6 +414,28 @@ static int h3_control_send(struct h3_uqs *h3_uqs, void *ctx)
return ret; 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>. /* 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 * 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. * to inform the QUIC mux layer of the encountered error.

View 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.st = QC_TX_SS_IDLE;
qcs->tx.bytes = qcs->tx.offset = 0; qcs->tx.bytes = qcs->tx.offset = 0;
qcs->tx.max_data = qcc->strms[qcs_type].tx.max_data; 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); eb64_insert(&qcc->streams_by_id, &qcs->by_id);
qcc->strms[qcs_type].nb_streams++; 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.max_data = qcc->strms[qcs_type].tx.max_data;
qcs->tx.offset = qcs->tx.bytes = 0; qcs->tx.offset = qcs->tx.bytes = 0;
qcs->tx.buf = BUF_NULL; qcs->tx.buf = BUF_NULL;
br_init(qcs->tx.mbuf, sizeof(qcs->tx.mbuf) / sizeof(qcs->tx.mbuf[0]));
qcs->subs = NULL; qcs->subs = NULL;
LIST_INIT(&qcs->list); 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.max_data = qcc->strms[qcs_type].rx.max_data;
qcs->rx.offset = qcs->rx.bytes = 0; qcs->rx.offset = qcs->rx.bytes = 0;
qcs->rx.buf = BUF_NULL; qcs->rx.buf = BUF_NULL;
br_init(qcs->tx.mbuf, sizeof(qcs->tx.mbuf) / sizeof(qcs->tx.mbuf[0]));
qcs->subs = NULL; qcs->subs = NULL;
LIST_INIT(&qcs->list); LIST_INIT(&qcs->list);