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

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

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