diff --git a/include/haproxy/mux_quic.h b/include/haproxy/mux_quic.h index f0c0a430e..715f7e9f5 100644 --- a/include/haproxy/mux_quic.h +++ b/include/haproxy/mux_quic.h @@ -11,6 +11,7 @@ #include #include #include +#include #include struct qcs *qcs_new(struct qcc *qcc, uint64_t id, enum qcs_type type); @@ -104,6 +105,19 @@ static inline struct qc_stream_desc *qcc_get_stream(struct qcc *qcc, uint64_t id return eb64_entry(node, struct qc_stream_desc, by_id); } +static inline struct conn_stream *qc_attach_cs(struct qcs *qcs, struct buffer *buf) +{ + struct conn_stream *cs = cs_new(); + if (!cs) + return NULL; + cs_attach_endp(cs, &qcs->qcc->conn->obj_type, qcs); + + cs->ctx = qcs; + stream_new(qcs->qcc->conn->owner, cs, buf); + + return cs; +} + #endif /* USE_QUIC */ #endif /* _HAPROXY_MUX_QUIC_H */ diff --git a/src/h3.c b/src/h3.c index a7968454a..3cce59563 100644 --- a/src/h3.c +++ b/src/h3.c @@ -24,12 +24,11 @@ #include #include #include -#include +#include #include #include #include #include -#include #include #include @@ -174,14 +173,10 @@ static int h3_headers_to_htx(struct qcs *qcs, struct buffer *buf, uint64_t len, if (fin) htx->flags |= HTX_FL_EOM; - cs = cs_new(); + cs = qc_attach_cs(qcs, &htx_buf); if (!cs) return 1; - cs_attach_endp(cs, &qcs->qcc->conn->obj_type, qcs); - cs->flags |= CS_FL_NOT_FIRST; - cs->ctx = qcs; - stream_new(qcs->qcc->conn->owner, cs, &htx_buf); /* buffer is transferred to conn_stream and set to NULL * except on stream creation error. diff --git a/src/hq_interop.c b/src/hq_interop.c index 0e5561d8a..79283736c 100644 --- a/src/hq_interop.c +++ b/src/hq_interop.c @@ -6,8 +6,7 @@ #include #include #include -#include -#include +#include static int hq_interop_decode_qcs(struct qcs *qcs, int fin, void *ctx) { @@ -72,12 +71,9 @@ static int hq_interop_decode_qcs(struct qcs *qcs, int fin, void *ctx) htx_add_endof(htx, HTX_BLK_EOH); htx_to_buf(htx, &htx_buf); - cs = cs_new(); + cs = qc_attach_cs(qcs, &htx_buf); if (!cs) return -1; - cs_attach_endp(cs, &qcs->qcc->conn->obj_type, qcs); - cs->ctx = qcs; - stream_new(qcs->qcc->conn->owner, cs, &htx_buf); b_del(rxbuf, b_data(rxbuf)); b_free(&htx_buf);