mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-02-17 19:16:56 +00:00
MINOR: mux-quic: clean up qcs Rx buffer allocation API
Replaces qcs_get_buf() function which naming does not reflect its purpose. Add a new function qcc_get_stream_rxbuf() which allocate if needed <qcs.rx.app_buf> and returns the buffer pointer. This function is reserved for application protocol layer. This buffer is then accessed by stconn layer. For other qcs_get_buf() invocation which was used in effect for a local buffer, replace these by a plain b_alloc().
This commit is contained in:
parent
14d968f2f2
commit
b526ffbfb9
@ -17,12 +17,12 @@ struct qcs *qcc_init_stream_local(struct qcc *qcc, int bidi);
|
||||
struct stconn *qcs_attach_sc(struct qcs *qcs, struct buffer *buf, char fin);
|
||||
int qcs_is_close_local(struct qcs *qcs);
|
||||
int qcs_is_close_remote(struct qcs *qcs);
|
||||
struct buffer *qcs_get_buf(struct qcs *qcs, struct buffer *bptr);
|
||||
|
||||
int qcs_subscribe(struct qcs *qcs, int event_type, struct wait_event *es);
|
||||
void qcs_notify_recv(struct qcs *qcs);
|
||||
void qcs_notify_send(struct qcs *qcs);
|
||||
|
||||
struct buffer *qcc_get_stream_rxbuf(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);
|
||||
|
8
src/h3.c
8
src/h3.c
@ -559,7 +559,7 @@ static ssize_t h3_headers_to_htx(struct qcs *qcs, const struct buffer *buf,
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!qcs_get_buf(qcs, &htx_buf)) {
|
||||
if (!b_alloc(&htx_buf)) {
|
||||
TRACE_ERROR("HTX buffer alloc failure", H3_EV_RX_FRAME|H3_EV_RX_HDR, qcs->qcc->conn, qcs);
|
||||
h3c->err = H3_INTERNAL_ERROR;
|
||||
len = -1;
|
||||
@ -938,7 +938,7 @@ static ssize_t h3_trailers_to_htx(struct qcs *qcs, const struct buffer *buf,
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!(appbuf = qcs_get_buf(qcs, &qcs->rx.app_buf))) {
|
||||
if (!(appbuf = qcc_get_stream_rxbuf(qcs))) {
|
||||
TRACE_ERROR("HTX buffer alloc failure", H3_EV_RX_FRAME|H3_EV_RX_HDR, qcs->qcc->conn, qcs);
|
||||
h3c->err = H3_INTERNAL_ERROR;
|
||||
len = -1;
|
||||
@ -1070,7 +1070,7 @@ static ssize_t h3_data_to_htx(struct qcs *qcs, const struct buffer *buf,
|
||||
|
||||
TRACE_ENTER(H3_EV_RX_FRAME|H3_EV_RX_DATA, qcs->qcc->conn, qcs);
|
||||
|
||||
if (!(appbuf = qcs_get_buf(qcs, &qcs->rx.app_buf))) {
|
||||
if (!(appbuf = qcc_get_stream_rxbuf(qcs))) {
|
||||
TRACE_ERROR("data buffer alloc failure", H3_EV_RX_FRAME|H3_EV_RX_DATA, qcs->qcc->conn, qcs);
|
||||
h3c->err = H3_INTERNAL_ERROR;
|
||||
len = -1;
|
||||
@ -1261,7 +1261,7 @@ static ssize_t h3_decode_qcs(struct qcs *qcs, struct buffer *b, int fin)
|
||||
struct htx *htx;
|
||||
|
||||
TRACE_PROTO("received FIN without data", H3_EV_RX_FRAME, qcs->qcc->conn, qcs);
|
||||
if (!(appbuf = qcs_get_buf(qcs, &qcs->rx.app_buf))) {
|
||||
if (!(appbuf = qcc_get_stream_rxbuf(qcs))) {
|
||||
TRACE_ERROR("data buffer alloc failure", H3_EV_RX_FRAME, qcs->qcc->conn, qcs);
|
||||
h3c->err = H3_INTERNAL_ERROR;
|
||||
goto err;
|
||||
|
@ -423,15 +423,6 @@ int qcs_is_close_remote(struct qcs *qcs)
|
||||
return qcs->st == QC_SS_HREM || qcs->st == QC_SS_CLO;
|
||||
}
|
||||
|
||||
/* Allocate if needed buffer <bptr> for stream <qcs>.
|
||||
*
|
||||
* Returns the buffer instance or NULL on allocation failure.
|
||||
*/
|
||||
struct buffer *qcs_get_buf(struct qcs *qcs, struct buffer *bptr)
|
||||
{
|
||||
return b_alloc(bptr);
|
||||
}
|
||||
|
||||
/* Allocate if needed buffer <ncbuf> for stream <qcs>.
|
||||
*
|
||||
* Returns the buffer instance or NULL on allocation failure.
|
||||
@ -914,6 +905,15 @@ static int qcc_decode_qcs(struct qcc *qcc, struct qcs *qcs)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Allocate if needed and retrieve <qcs> stream buffer for data reception.
|
||||
*
|
||||
* Returns buffer pointer. May be NULL on allocation failure.
|
||||
*/
|
||||
struct buffer *qcc_get_stream_rxbuf(struct qcs *qcs)
|
||||
{
|
||||
return b_alloc(&qcs->rx.app_buf);
|
||||
}
|
||||
|
||||
/* Prepare for the emission of RESET_STREAM on <qcs> with error code <err>. */
|
||||
void qcc_reset_stream(struct qcs *qcs, int err)
|
||||
{
|
||||
@ -1510,7 +1510,7 @@ static int qcs_xfer_data(struct qcs *qcs, struct buffer *out, struct buffer *in)
|
||||
|
||||
TRACE_ENTER(QMUX_EV_QCS_SEND, qcc->conn, qcs);
|
||||
|
||||
if (!qcs_get_buf(qcs, out)) {
|
||||
if (!b_alloc(out)) {
|
||||
TRACE_ERROR("buffer alloc failure", QMUX_EV_QCS_SEND, qcc->conn, qcs);
|
||||
goto err;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user