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))
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;
}
}
/* 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);