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.
This commit is contained in:
Amaury Denoyelle 2022-05-24 16:53:56 +02:00
parent 93fba32430
commit 1c25b18e17
2 changed files with 12 additions and 12 deletions

View 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;

View 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) {