From 1c25b18e17e87070d48531361bb7285f04d5f3e0 Mon Sep 17 00:00:00 2001 From: Amaury Denoyelle Date: Tue, 24 May 2022 16:53:56 +0200 Subject: [PATCH] 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. --- include/haproxy/mux_quic.h | 13 +++++++++++-- src/mux_quic.c | 11 +---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/haproxy/mux_quic.h b/include/haproxy/mux_quic.h index 87d1b9987..c9bb8bf55 100644 --- a/include/haproxy/mux_quic.h +++ b/include/haproxy/mux_quic.h @@ -92,7 +92,16 @@ static inline int qcc_install_app_ops(struct qcc *qcc, 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 @@ static inline struct conn_stream *qc_attach_cs(struct qcs *qcs, struct buffer *b 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 31dbdd984..f6655f626 100644 --- a/src/mux_quic.c +++ b/src/mux_quic.c @@ -141,15 +141,6 @@ struct qcs *qcs_new(struct qcc *qcc, uint64_t id, enum qcs_type type) 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 @@ static int qc_wake_some_streams(struct qcc *qcc) 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) {