MINOR: quic: Make use of the last cbuf API when initializing TX ring buffers

Initialize the circular buffer internal buffer from a specific pool for TX ring
buffers named "pool_head_quic_tx_ring".
This commit is contained in:
Frédéric Lécaille 2021-08-04 15:10:32 +02:00 committed by Amaury Denoyelle
parent dbe25afbe6
commit 8b19a9f162

View File

@ -537,20 +537,29 @@ static int quic_alloc_rings_listener(struct listener *l)
MT_LIST_INIT(&l->rx.tx_qrings); MT_LIST_INIT(&l->rx.tx_qrings);
for (i = 0; i < global.nbthread; i++) { for (i = 0; i < global.nbthread; i++) {
unsigned char *buf;
struct qring *qr = &l->rx.qrings[i]; struct qring *qr = &l->rx.qrings[i];
qr->cbuf = cbuf_new(); buf = pool_alloc(pool_head_quic_tx_ring);
if (!qr->cbuf) if (!buf)
goto err; goto err;
qr->cbuf = cbuf_new(buf, QUIC_TX_RING_BUFSZ);
if (!qr->cbuf) {
pool_free(pool_head_quic_tx_ring, buf);
goto err;
}
MT_LIST_APPEND(&l->rx.tx_qrings, &qr->mt_list); MT_LIST_APPEND(&l->rx.tx_qrings, &qr->mt_list);
} }
return 1; return 1;
err: err:
while ((qr = MT_LIST_POP(&l->rx.tx_qrings, typeof(qr), mt_list))) while ((qr = MT_LIST_POP(&l->rx.tx_qrings, typeof(qr), mt_list))) {
pool_free(pool_head_quic_tx_ring, qr->cbuf->buf);
cbuf_free(qr->cbuf); cbuf_free(qr->cbuf);
}
free(l->rx.qrings); free(l->rx.qrings);
return 0; return 0;
} }