diff --git a/src/mux_quic.c b/src/mux_quic.c index 78baccb82..9df32be52 100644 --- a/src/mux_quic.c +++ b/src/mux_quic.c @@ -1158,6 +1158,7 @@ int qcc_realign_stream_txbuf(const struct qcs *qcs, struct buffer *out) */ int qcc_release_stream_txbuf(struct qcs *qcs) { + struct buffer *buf = qc_stream_buf_get(qcs->stream); const uint64_t bytes = qcs_prep_bytes(qcs); /* Cannot release buffer if prepared data is not fully sent. */ @@ -1166,7 +1167,10 @@ int qcc_release_stream_txbuf(struct qcs *qcs) return 1; } + /* Free released buf size from buf window. */ qc_stream_buf_release(qcs->stream); + qcc_notify_buf(qcs->qcc, b_size(buf)); + return 0; } @@ -1975,7 +1979,7 @@ void qcc_streams_sent_done(struct qcs *qcs, uint64_t data, uint64_t offset) /* Release buffer if everything sent and buf is full or stream is waiting for room. */ if (!qcs_prep_bytes(qcs) && (b_full(&qcs->stream->buf->buf) || qcs->flags & QC_SF_BLK_MROOM)) { - qc_stream_buf_release(qcs->stream); + qcc_release_stream_txbuf(qcs); qcs->flags &= ~QC_SF_BLK_MROOM; qcs_notify_send(qcs); } diff --git a/src/quic_stream.c b/src/quic_stream.c index bf9a54e62..587b5a1ca 100644 --- a/src/quic_stream.c +++ b/src/quic_stream.c @@ -30,15 +30,22 @@ static void qc_stream_buf_free(struct qc_stream_desc *stream, { struct quic_conn *qc = stream->qc; struct buffer *buf = &(*stream_buf)->buf; - uint64_t free_size; LIST_DEL_INIT(&(*stream_buf)->list); /* Reset current buf ptr if deleted instance is the same one. */ - if (*stream_buf == stream->buf) + if (*stream_buf == stream->buf) { stream->buf = NULL; - free_size = b_size(buf); + /* Only non-released buffer are notified to MUX layer. */ + 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, b_size(buf)); + } + } + } + if ((*stream_buf)->sbuf) { pool_free(pool_head_sbuf, buf->area); } @@ -48,14 +55,6 @@ static void qc_stream_buf_free(struct qc_stream_desc *stream, } pool_free(pool_head_quic_stream_buf, *stream_buf); *stream_buf = NULL; - - /* notify MUX about available buffers. */ - 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); - } - } } /* Allocate a new stream descriptor with id . The caller is responsible to @@ -124,6 +123,9 @@ void qc_stream_desc_release(struct qc_stream_desc *stream, /* final_size cannot be greater than all currently stored data. */ BUG_ON(final_size > tail_offset); + /* release buffer and notify MUX. */ + qcc_notify_buf(stream->qc->qcc, b_size(buf)); + /* Remove unsent data from current buffer. */ if (final_size < tail_offset) b_sub(buf, tail_offset - final_size); @@ -209,7 +211,6 @@ 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)); @@ -217,7 +218,6 @@ void qc_stream_desc_free(struct qc_stream_desc *stream, int closing) /* 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 @@ -228,17 +228,9 @@ void qc_stream_desc_free(struct qc_stream_desc *stream, int closing) } } - 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. */