mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-11-28 06:11:32 +01:00
MINOR: mux-quic: clean up qcs Tx buffer allocation API
This function is similar to the previous one, but this time for QCS sending buffer. Previously, each application layer redefine their own version of mux_get_buf() which was used to allocate <qcs.tx.buf>. Unify it under a single function renamed qcc_get_stream_txbuf().
This commit is contained in:
parent
b526ffbfb9
commit
f496c7469b
@ -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);
|
||||
|
||||
30
src/h3.c
30
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 <qcs> 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);
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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 <qcs> 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 <qcs> with error code <err>. */
|
||||
void qcc_reset_stream(struct qcs *qcs, int err)
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user