MINOR: mux-quic: delay cs_endpoint allocation
Do not allocate cs_endpoint for every QCS instances in qcs_new().
Instead, this is delayed to qc_attach_cs() function.
In effect, with H3 as app protocol, cs_endpoint will be allocated on
HEADERS parsing. Thus, no cs_endpoint is allocated for H3 unidirectional
streams which do not convey any HTTP data.
diff --git a/include/haproxy/mux_quic.h b/include/haproxy/mux_quic.h
index 87d1b99..c9bb8bf 100644
--- a/include/haproxy/mux_quic.h
+++ b/include/haproxy/mux_quic.h
@@ -92,7 +92,16 @@
static inline struct conn_stream *qc_attach_cs(struct qcs *qcs, struct buffer *buf)
{
- struct session *sess = qcs->qcc->conn->owner;
+ struct qcc *qcc = qcs->qcc;
+ struct session *sess = qcc->conn->owner;
+
+ qcs->endp = cs_endpoint_new();
+ if (!qcs->endp)
+ return NULL;
+
+ qcs->endp->target = qcs;
+ qcs->endp->ctx = qcc->conn;
+ qcs->endp->flags |= (CS_EP_T_MUX|CS_EP_ORPHAN|CS_EP_NOT_FIRST);
/* TODO duplicated from mux_h2 */
sess->t_idle = tv_ms_elapsed(&sess->tv_accept, &now) - sess->t_handshake;
@@ -100,7 +109,7 @@
if (!cs_new_from_endp(qcs->endp, sess, buf))
return NULL;
- ++qcs->qcc->nb_cs;
+ ++qcc->nb_cs;
/* TODO duplicated from mux_h2 */
sess->accept_date = date;
diff --git a/src/mux_quic.c b/src/mux_quic.c
index 31dbdd9..f6655f6 100644
--- a/src/mux_quic.c
+++ b/src/mux_quic.c
@@ -141,15 +141,6 @@
goto err;
}
- qcs->endp = cs_endpoint_new();
- if (!qcs->endp) {
- pool_free(pool_head_qcs, qcs);
- goto err;
- }
- qcs->endp->target = qcs;
- qcs->endp->ctx = qcc->conn;
- qcs->endp->flags |= (CS_EP_T_MUX|CS_EP_ORPHAN|CS_EP_NOT_FIRST);
-
qcs->id = qcs->by_id.key = id;
/* store transport layer stream descriptor in qcc tree */
eb64_insert(&qcc->streams_by_id, &qcs->by_id);
@@ -1533,7 +1524,7 @@
node = eb64_next(node)) {
qcs = eb64_entry(node, struct qcs, by_id);
- if (!qcs->endp->cs)
+ if (!qcs->endp || !qcs->endp->cs)
continue;
if (qcc->conn->flags & CO_FL_ERROR) {