diff --git a/include/haproxy/mux_quic.h b/include/haproxy/mux_quic.h index ca5cd56e7..b91ccdcbd 100644 --- a/include/haproxy/mux_quic.h +++ b/include/haproxy/mux_quic.h @@ -23,6 +23,7 @@ void qcs_notify_recv(struct qcs *qcs); void qcs_notify_send(struct qcs *qcs); struct buffer *qcc_get_stream_rxbuf(struct qcs *qcs); +struct buffer *qcc_get_stream_txbuf(struct qcs *qcs); void qcc_reset_stream(struct qcs *qcs, int err); void qcc_send_stream(struct qcs *qcs, int urg); void qcc_abort_stream_read(struct qcs *qcs); diff --git a/src/h3.c b/src/h3.c index d7bf11010..ba488f26f 100644 --- a/src/h3.c +++ b/src/h3.c @@ -1415,17 +1415,6 @@ static ssize_t h3_decode_qcs(struct qcs *qcs, struct buffer *b, int fin) return -1; } -/* Returns buffer for data sending. - * May be NULL if the allocation failed. - */ -static struct buffer *mux_get_buf(struct qcs *qcs) -{ - if (!b_size(&qcs->tx.buf)) - b_alloc(&qcs->tx.buf); - - return &qcs->tx.buf; -} - /* Function used to emit stream data from control uni-stream */ static int h3_control_send(struct qcs *qcs, void *ctx) { @@ -1464,7 +1453,7 @@ static int h3_control_send(struct qcs *qcs, void *ctx) b_quic_enc_int(&pos, h3_settings_max_field_section_size, 0); } - res = mux_get_buf(qcs); + res = qcc_get_stream_txbuf(qcs); if (b_room(res) < b_data(&pos)) { // TODO the mux should be put in blocked state, with // the stream in state waiting for settings to be sent @@ -1533,7 +1522,8 @@ static int h3_resp_headers_send(struct qcs *qcs, struct htx *htx) list[hdr].n = ist(""); - res = mux_get_buf(qcs); + if (!(res = qcc_get_stream_txbuf(qcs))) + goto err; /* At least 5 bytes to store frame type + length as a varint max size */ if (b_room(res) < 5) @@ -1663,7 +1653,8 @@ static int h3_resp_trailers_send(struct qcs *qcs, struct htx *htx) } list[hdr].n = ist(""); - res = mux_get_buf(qcs); + if (!(res = qcc_get_stream_txbuf(qcs))) + goto err; /* At least 9 bytes to store frame type + length as a varint max size */ if (b_room(res) < 9) { @@ -1769,7 +1760,9 @@ static int h3_resp_data_send(struct qcs *qcs, struct buffer *buf, size_t count) if (type != HTX_BLK_DATA) goto end; - res = mux_get_buf(qcs); + if (!(res = qcc_get_stream_txbuf(qcs))) { + /* TODO */ + } if (unlikely(fsize == count && !b_data(res) && @@ -1947,8 +1940,9 @@ static size_t h3_nego_ff(struct qcs *qcs, size_t count) h3_debug_printf(stderr, "%s\n", __func__); - /* FIXME: no check on ALLOC ? */ - res = mux_get_buf(qcs); + if (!(res = qcc_get_stream_txbuf(qcs))) { + /* TODO */ + } /* h3 DATA headers : 1-byte frame type + varint frame length */ hsize = 1 + QUIC_VARINT_MAX_SIZE; @@ -2154,7 +2148,7 @@ static int h3_send_goaway(struct h3c *h3c) b_quic_enc_int(&pos, frm_len, 0); b_quic_enc_int(&pos, h3c->id_goaway, 0); - res = mux_get_buf(qcs); + res = qcc_get_stream_txbuf(qcs); if (!res || b_room(res) < b_data(&pos)) { /* Do not try forcefully to emit GOAWAY if no space left. */ TRACE_ERROR("cannot send GOAWAY", H3_EV_H3C_END, h3c->qcc->conn, qcs); diff --git a/src/hq_interop.c b/src/hq_interop.c index ae4140a88..ba2f0c7db 100644 --- a/src/hq_interop.c +++ b/src/hq_interop.c @@ -83,14 +83,6 @@ static ssize_t hq_interop_decode_qcs(struct qcs *qcs, struct buffer *b, int fin) return b_data(b); } -static struct buffer *mux_get_buf(struct qcs *qcs) -{ - if (!b_size(&qcs->tx.buf)) - b_alloc(&qcs->tx.buf); - - return &qcs->tx.buf; -} - static size_t hq_interop_snd_buf(struct qcs *qcs, struct buffer *buf, size_t count) { @@ -102,7 +94,7 @@ static size_t hq_interop_snd_buf(struct qcs *qcs, struct buffer *buf, struct buffer *res, outbuf; size_t total = 0; - res = mux_get_buf(qcs); + res = qcc_get_stream_txbuf(qcs); outbuf = b_make(b_tail(res), b_contig_space(res), 0, 0); htx = htx_from_buf(buf); @@ -163,7 +155,7 @@ static size_t hq_interop_snd_buf(struct qcs *qcs, struct buffer *buf, static size_t hq_interop_nego_ff(struct qcs *qcs, size_t count) { - struct buffer *res = mux_get_buf(qcs); + struct buffer *res = qcc_get_stream_txbuf(qcs); if (!b_room(res)) { qcs->flags |= QC_SF_BLK_MROOM; diff --git a/src/mux_quic.c b/src/mux_quic.c index 4fbef0d9d..4422e0ba1 100644 --- a/src/mux_quic.c +++ b/src/mux_quic.c @@ -914,6 +914,15 @@ struct buffer *qcc_get_stream_rxbuf(struct qcs *qcs) return b_alloc(&qcs->rx.app_buf); } +/* Allocate if needed and retrieve stream buffer for data emission. + * + * Returns buffer pointer. May be NULL on allocation failure. + */ +struct buffer *qcc_get_stream_txbuf(struct qcs *qcs) +{ + return b_alloc(&qcs->tx.buf); +} + /* Prepare for the emission of RESET_STREAM on with error code . */ void qcc_reset_stream(struct qcs *qcs, int err) {