From: Amaury Denoyelle Date: Tue, 24 May 2022 14:53:14 +0000 (+0200) Subject: MINOR: mux-quic: do not alloc quic_stream_desc for uni remote stream X-Git-Tag: v2.6-dev12~135 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=93fba32430ad9cb8fc95ffb696ee35adbbee0c86;p=thirdparty%2Fhaproxy.git MINOR: mux-quic: do not alloc quic_stream_desc for uni remote stream qc_stream_desc type is required for sending. Thus, it is not required for an unidirectional remote stream where only receive will be performed. --- diff --git a/src/mux_quic.c b/src/mux_quic.c index 5fafb22b54..31dbdd984d 100644 --- a/src/mux_quic.c +++ b/src/mux_quic.c @@ -128,14 +128,13 @@ struct qcs *qcs_new(struct qcc *qcc, uint64_t id, enum qcs_type type) qcs->flags = QC_SF_NONE; qcs->ctx = NULL; - /* allocate transport layer stream descriptor - * - * TODO qc_stream_desc is only useful for Tx buffering. It should not - * be required for unidirectional remote streams. - */ - qcs->stream = qc_stream_desc_new(id, type, qcs, qcc->conn->handle.qc); - if (!qcs->stream) - goto err; + /* Allocate transport layer stream descriptor. Only needed for TX. */ + if (!quic_stream_is_uni(id) || !quic_stream_is_remote(qcc, id)) { + struct quic_conn *qc = qcc->conn->handle.qc; + qcs->stream = qc_stream_desc_new(id, type, qcs, qc); + if (!qcs->stream) + goto err; + } if (qcc->app_ops->attach) { if (qcc->app_ops->attach(qcs)) @@ -187,9 +186,7 @@ struct qcs *qcs_new(struct qcc *qcc, uint64_t id, enum qcs_type type) if (qcs->ctx && qcc->app_ops->detach) qcc->app_ops->detach(qcs); - if (qcs->stream) - qc_stream_desc_release(qcs->stream); - + qc_stream_desc_release(qcs->stream); pool_free(pool_head_qcs, qcs); return NULL; } diff --git a/src/quic_stream.c b/src/quic_stream.c index 0d9e12ab64..a0ac936bdb 100644 --- a/src/quic_stream.c +++ b/src/quic_stream.c @@ -47,10 +47,14 @@ struct qc_stream_desc *qc_stream_desc_new(uint64_t id, enum qcs_type type, void } /* Mark the stream descriptor as released. It will be freed as soon as - * all its buffered data are acknowledged. + * all its buffered data are acknowledged. Does nothing if is already + * NULL. */ void qc_stream_desc_release(struct qc_stream_desc *stream) { + if (!stream) + return; + /* A stream can be released only one time. */ BUG_ON(stream->release);