mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-08 08:07:10 +02:00
MINOR: quic: Remove old TX buffer implementation
We use only ring buffers (struct qring) to prepare and send QUIC datagrams. We can safely remove the old buffering implementation which was not thread safe.
This commit is contained in:
parent
98ad56a049
commit
c8d3f873e8
@ -623,8 +623,6 @@ struct quic_conn {
|
|||||||
/* The remaining frames to send. */
|
/* The remaining frames to send. */
|
||||||
struct list frms_to_send;
|
struct list frms_to_send;
|
||||||
|
|
||||||
/* Array of buffers. */
|
|
||||||
struct q_buf **bufs;
|
|
||||||
/* The size of the previous array. */
|
/* The size of the previous array. */
|
||||||
size_t nb_buf;
|
size_t nb_buf;
|
||||||
/* Writer index. */
|
/* Writer index. */
|
||||||
|
@ -1009,77 +1009,6 @@ static inline int c_buf_consumed(struct quic_enc_level *qel)
|
|||||||
return qel->tx.crypto.offset == qel->tx.crypto.sz;
|
return qel->tx.crypto.offset == qel->tx.crypto.sz;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* QUIC buffer handling functions */
|
|
||||||
|
|
||||||
/* Returns the current buffer which may be used to build outgoing packets. */
|
|
||||||
static inline struct q_buf *q_wbuf(struct quic_conn *qc)
|
|
||||||
{
|
|
||||||
return qc->tx.bufs[qc->tx.wbuf];
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline struct q_buf *q_rbuf(struct quic_conn *qc)
|
|
||||||
{
|
|
||||||
return qc->tx.bufs[qc->tx.rbuf];
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Returns the next buffer to be used to send packets from. */
|
|
||||||
static inline struct q_buf *q_next_rbuf(struct quic_conn *qc)
|
|
||||||
{
|
|
||||||
qc->tx.rbuf = (qc->tx.rbuf + 1) & (QUIC_CONN_TX_BUFS_NB - 1);
|
|
||||||
return q_rbuf(qc);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Return the next buffer which may be used to build outgoing packets.
|
|
||||||
* Also decrement by one the number of remaining probing datagrams
|
|
||||||
* which may be sent.
|
|
||||||
*/
|
|
||||||
static inline struct q_buf *q_next_wbuf(struct quic_conn *qc)
|
|
||||||
{
|
|
||||||
qc->tx.wbuf = (qc->tx.wbuf + 1) & (QUIC_CONN_TX_BUFS_NB - 1);
|
|
||||||
/* Decrement the number of prepared datagrams (only when probing). */
|
|
||||||
if (qc->tx.nb_pto_dgrams)
|
|
||||||
--qc->tx.nb_pto_dgrams;
|
|
||||||
return q_wbuf(qc);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Return the position of <buf> buffer to be used to write outgoing packets. */
|
|
||||||
static inline unsigned char *q_buf_getpos(struct q_buf *buf)
|
|
||||||
{
|
|
||||||
return buf->pos;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Return the pointer to one past the end of <buf> buffer. */
|
|
||||||
static inline const unsigned char *q_buf_end(struct q_buf *buf)
|
|
||||||
{
|
|
||||||
return buf->end;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set the position of <buf> buffer to <pos> value. */
|
|
||||||
static inline void q_buf_setpos(struct q_buf *buf, unsigned char *pos)
|
|
||||||
{
|
|
||||||
buf->pos = pos;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Returns the remaining amount of room left in <buf> buffer. */
|
|
||||||
static inline ssize_t q_buf_room(struct q_buf *buf)
|
|
||||||
{
|
|
||||||
return q_buf_end(buf) - q_buf_getpos(buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Reset (or empty) <buf> buffer to prepare it for the next writing. */
|
|
||||||
static inline void q_buf_reset(struct q_buf *buf)
|
|
||||||
{
|
|
||||||
buf->pos = buf->area;
|
|
||||||
buf->data = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Returns 1 if <buf> is empty, 0 if not. */
|
|
||||||
static inline int q_buf_empty(struct q_buf *buf)
|
|
||||||
{
|
|
||||||
return !buf->data;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Return 1 if <pkt> header form is long, 0 if not. */
|
/* Return 1 if <pkt> header form is long, 0 if not. */
|
||||||
static inline int qc_pkt_long(const struct quic_rx_packet *pkt)
|
static inline int qc_pkt_long(const struct quic_rx_packet *pkt)
|
||||||
{
|
{
|
||||||
|
@ -2741,66 +2741,6 @@ static int quic_conn_enc_level_init(struct quic_conn *qc,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Release the memory allocated for <buf> array of buffers, with <nb> as size.
|
|
||||||
* Never fails.
|
|
||||||
*/
|
|
||||||
static inline void free_quic_conn_tx_bufs(struct q_buf **bufs, size_t nb)
|
|
||||||
{
|
|
||||||
struct q_buf **p;
|
|
||||||
|
|
||||||
if (!bufs)
|
|
||||||
return;
|
|
||||||
|
|
||||||
p = bufs;
|
|
||||||
while (--nb) {
|
|
||||||
if (!*p) {
|
|
||||||
p++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
ha_free(&(*p)->area);
|
|
||||||
ha_free(p);
|
|
||||||
p++;
|
|
||||||
}
|
|
||||||
free(bufs);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Allocate an array or <nb> buffers of <sz> bytes each.
|
|
||||||
* Return this array if succeeded, NULL if failed.
|
|
||||||
*/
|
|
||||||
static inline struct q_buf **quic_conn_tx_bufs_alloc(size_t nb, size_t sz)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
struct q_buf **bufs, **p;
|
|
||||||
|
|
||||||
bufs = calloc(nb, sizeof *bufs);
|
|
||||||
if (!bufs)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
i = 0;
|
|
||||||
p = bufs;
|
|
||||||
while (i++ < nb) {
|
|
||||||
*p = calloc(1, sizeof **p);
|
|
||||||
if (!*p)
|
|
||||||
goto err;
|
|
||||||
|
|
||||||
(*p)->area = malloc(sz);
|
|
||||||
if (!(*p)->area)
|
|
||||||
goto err;
|
|
||||||
|
|
||||||
(*p)->pos = (*p)->area;
|
|
||||||
(*p)->end = (*p)->area + sz;
|
|
||||||
(*p)->data = 0;
|
|
||||||
LIST_INIT(&(*p)->pkts);
|
|
||||||
p++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return bufs;
|
|
||||||
|
|
||||||
err:
|
|
||||||
free_quic_conn_tx_bufs(bufs, nb);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Release all the memory allocated for <conn> QUIC connection. */
|
/* Release all the memory allocated for <conn> QUIC connection. */
|
||||||
static void quic_conn_free(struct quic_conn *conn)
|
static void quic_conn_free(struct quic_conn *conn)
|
||||||
{
|
{
|
||||||
@ -2812,7 +2752,6 @@ static void quic_conn_free(struct quic_conn *conn)
|
|||||||
free_quic_conn_cids(conn);
|
free_quic_conn_cids(conn);
|
||||||
for (i = 0; i < QUIC_TLS_ENC_LEVEL_MAX; i++)
|
for (i = 0; i < QUIC_TLS_ENC_LEVEL_MAX; i++)
|
||||||
quic_conn_enc_level_uninit(&conn->els[i]);
|
quic_conn_enc_level_uninit(&conn->els[i]);
|
||||||
free_quic_conn_tx_bufs(conn->tx.bufs, conn->tx.nb_buf);
|
|
||||||
if (conn->timer_task)
|
if (conn->timer_task)
|
||||||
task_destroy(conn->timer_task);
|
task_destroy(conn->timer_task);
|
||||||
pool_free(pool_head_quic_conn, conn);
|
pool_free(pool_head_quic_conn, conn);
|
||||||
@ -2938,15 +2877,9 @@ static struct quic_conn *qc_new_conn(unsigned int version, int ipv4,
|
|||||||
qc->els[i].pktns = &qc->pktns[quic_tls_pktns(i)];
|
qc->els[i].pktns = &qc->pktns[quic_tls_pktns(i)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qc->version = version;
|
||||||
/* TX part. */
|
/* TX part. */
|
||||||
LIST_INIT(&qc->tx.frms_to_send);
|
LIST_INIT(&qc->tx.frms_to_send);
|
||||||
qc->tx.bufs = quic_conn_tx_bufs_alloc(QUIC_CONN_TX_BUFS_NB, QUIC_CONN_TX_BUF_SZ);
|
|
||||||
if (!qc->tx.bufs) {
|
|
||||||
TRACE_PROTO("Could not allocate TX bufs", QUIC_EV_CONN_INIT);
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
|
|
||||||
qc->version = version;
|
|
||||||
qc->tx.nb_buf = QUIC_CONN_TX_BUFS_NB;
|
qc->tx.nb_buf = QUIC_CONN_TX_BUFS_NB;
|
||||||
qc->tx.wbuf = qc->tx.rbuf = 0;
|
qc->tx.wbuf = qc->tx.rbuf = 0;
|
||||||
qc->tx.bytes = 0;
|
qc->tx.bytes = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user