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 5fafb22..31dbdd9 100644
--- a/src/mux_quic.c
+++ b/src/mux_quic.c
@@ -128,14 +128,13 @@
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 @@
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 0d9e12a..a0ac936 100644
--- a/src/quic_stream.c
+++ b/src/quic_stream.c
@@ -47,10 +47,14 @@
}
/* 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);