]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: mux-quic: delay cs_endpoint allocation
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 24 May 2022 14:53:56 +0000 (16:53 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 25 May 2022 13:41:25 +0000 (15:41 +0200)
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
src/mux_quic.c

index 87d1b9987dc81dbec1430cb672a8f43a05fdcfcf..c9bb8bf5581ed10df35b5e6c9b30a9dd33262ca2 100644 (file)
@@ -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;
index 31dbdd984dbd85a4d7a6c68ba8f088c7f498641c..f6655f62676dd600a50befc9ebf4570a39f40894 100644 (file)
@@ -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) {