From 4859d8e71d9ccefcb64a474871c9a537872af646 Mon Sep 17 00:00:00 2001 From: Amaury Denoyelle Date: Fri, 27 Sep 2024 15:31:21 +0200 Subject: [PATCH] MINOR: quic: remove unneeded notification of txbuf room When a stream buffer is freed, qc_stream_desc notify MUX. This is useful if MUX is waiting for Tx buffer allocation. Remove this notification in qc_stream_desc(). This is because the function is called when all stream data have been acknowledged and thus notified. This function can also be called with some data unacknowledged, but in this case this is only true just before connection closure. As such, it is useful to notify the MUX in this condition. --- src/quic_stream.c | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/src/quic_stream.c b/src/quic_stream.c index 7181e0034..91f657d47 100644 --- a/src/quic_stream.c +++ b/src/quic_stream.c @@ -209,36 +209,32 @@ void qc_stream_desc_free(struct qc_stream_desc *stream, int closing) struct quic_conn *qc = stream->qc; struct eb64_node *frm_node; unsigned int free_count = 0; - uint64_t free_size = 0; /* This function only deals with released streams. */ BUG_ON(!(stream->flags & QC_SD_FL_RELEASE)); /* free remaining stream buffers */ list_for_each_entry_safe(buf, buf_back, &stream->buf_list, list) { - if (!(b_data(&buf->buf)) || closing) { - free_size += b_size(&buf->buf); - if (buf->sbuf) - pool_free(pool_head_sbuf, buf->buf.area); - else - b_free(&buf->buf); - LIST_DELETE(&buf->list); - pool_free(pool_head_quic_stream_buf, buf); - ++free_count; - } + + /* qc_stream_desc_free() can only be used after all data is + * acknowledged or on connection shutdown. In the contrary + * case, MUX must be notified about room available. + */ + BUG_ON(b_data(&buf->buf) && !closing); + + if (buf->sbuf) + pool_free(pool_head_sbuf, buf->buf.area); + else + b_free(&buf->buf); + + LIST_DELETE(&buf->list); + pool_free(pool_head_quic_stream_buf, buf); + ++free_count; } - if (free_count) { + if (free_count) offer_buffers(NULL, free_count); - if (qc->mux_state == QC_MUX_READY) { - if (!(stream->flags & QC_SD_FL_OOB_BUF)) { - /* notify MUX about available buffers. */ - qcc_notify_buf(qc->qcc, free_size); - } - } - } - /* qc_stream_desc might be freed before having received all its ACKs. * This is the case if some frames were retransmitted. */