]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: mux-quic: do not alloc quic_stream_desc for uni remote stream
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 24 May 2022 14:53:14 +0000 (16:53 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 25 May 2022 13:41:25 +0000 (15:41 +0200)
qc_stream_desc type is required for sending. Thus, it is not required
for an unidirectional remote stream where only receive will be
performed.

src/mux_quic.c
src/quic_stream.c

index 5fafb22b546d692b76d23c7bba3ffae814809ac8..31dbdd984dbd85a4d7a6c68ba8f088c7f498641c 100644 (file)
@@ -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;
 }
index 0d9e12ab641ef5c0b6d230673bb305d31837f2ba..a0ac936bdb9b5bbfe1a86888f8afb920bbcb5723 100644 (file)
@@ -47,10 +47,14 @@ struct qc_stream_desc *qc_stream_desc_new(uint64_t id, enum qcs_type type, void
 }
 
 /* Mark the stream descriptor <stream> as released. It will be freed as soon as
- * all its buffered data are acknowledged.
+ * all its buffered data are acknowledged. Does nothing if <stream> 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);