mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-06 23:27:04 +02:00
BUG/MINOR: h3: properly handle alloc failure on finalize
If H3 control stream Tx buffer cannot be allocated, return a proper errur through h3_finalize(). This will cause the emission of a CONNECTION_CLOSE with error H3_INTERNAL_ERROR and closure of the whole connection. This should be backported up to 2.6. Note that 2.9 has some difference which will cause conflict. The main one is that qcc_get_stream_txbuf() does not exist in this version. Instead the check in h3_control_send() should be made after mux_get_buf(). Finally, it may be useful to first pick previous commit (MINOR: h3: add traces for connection init stage) to improve context similarity.
This commit is contained in:
parent
a2dbd6d916
commit
7a3602a1f5
20
src/h3.c
20
src/h3.c
@ -1418,7 +1418,11 @@ static ssize_t h3_rcv_buf(struct qcs *qcs, struct buffer *b, int fin)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Function used to emit stream data from <qcs> control uni-stream */
|
||||
/* Function used to emit stream data from <qcs> control uni-stream.
|
||||
*
|
||||
* On success return the number of sent bytes. A negative code is used on
|
||||
* error.
|
||||
*/
|
||||
static int h3_control_send(struct qcs *qcs, void *ctx)
|
||||
{
|
||||
int ret;
|
||||
@ -1456,7 +1460,11 @@ static int h3_control_send(struct qcs *qcs, void *ctx)
|
||||
b_quic_enc_int(&pos, h3_settings_max_field_section_size, 0);
|
||||
}
|
||||
|
||||
res = qcc_get_stream_txbuf(qcs);
|
||||
if (!(res = qcc_get_stream_txbuf(qcs))) {
|
||||
TRACE_ERROR("cannot allocate Tx buffer", H3_EV_TX_FRAME|H3_EV_TX_SETTINGS, qcs->qcc->conn, qcs);
|
||||
goto err;
|
||||
}
|
||||
|
||||
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
|
||||
@ -1472,6 +1480,10 @@ static int h3_control_send(struct qcs *qcs, void *ctx)
|
||||
|
||||
TRACE_LEAVE(H3_EV_TX_FRAME|H3_EV_TX_SETTINGS, qcs->qcc->conn, qcs);
|
||||
return ret;
|
||||
|
||||
err:
|
||||
TRACE_DEVEL("leaving on error", H3_EV_TX_FRAME|H3_EV_TX_SETTINGS, qcs->qcc->conn, qcs);
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int h3_resp_headers_send(struct qcs *qcs, struct htx *htx)
|
||||
@ -2226,9 +2238,11 @@ static int h3_finalize(void *ctx)
|
||||
goto err;
|
||||
}
|
||||
|
||||
h3_control_send(qcs, h3c);
|
||||
h3c->ctrl_strm = qcs;
|
||||
|
||||
if (h3_control_send(qcs, h3c) < 0)
|
||||
goto err;
|
||||
|
||||
TRACE_LEAVE(H3_EV_H3C_NEW, qcc->conn);
|
||||
return 0;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user