diff options
author | Hugo Landau <hlandau@openssl.org> | 2023-04-18 19:30:56 +0100 |
---|---|---|
committer | Hugo Landau <hlandau@openssl.org> | 2023-05-12 14:47:13 +0100 |
commit | 0847e63ee5d58d824390aadcbcf10281c45900c4 (patch) | |
tree | 5dfd6836eb30316eb68fa0ea8c5d538cc27d9874 /ssl/quic/quic_sstream.c | |
parent | 9cacba434b027bc6f3a3f3c4255c2453935e5357 (diff) |
QUIC QSM: Stream garbage collection
This allows QUIC_STREAM objects to be deleted when they are no longer
needed.
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20765)
Diffstat (limited to 'ssl/quic/quic_sstream.c')
-rw-r--r-- | ssl/quic/quic_sstream.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/ssl/quic/quic_sstream.c b/ssl/quic/quic_sstream.c index a0ef4e9eae..0e15dde51d 100644 --- a/ssl/quic/quic_sstream.c +++ b/ssl/quic/quic_sstream.c @@ -372,6 +372,27 @@ size_t ossl_quic_sstream_get_buffer_avail(QUIC_SSTREAM *qss) return ring_buf_avail(&qss->ring_buf); } +int ossl_quic_sstream_is_totally_acked(QUIC_SSTREAM *qss) +{ + UINT_RANGE r; + uint64_t cur_size; + + if ((qss->have_final_size && !qss->acked_final_size) + || ossl_list_uint_set_num(&qss->acked_set) != 1) + return 0; + + r = ossl_list_uint_set_head(&qss->acked_set)->range; + cur_size = qss->ring_buf.head_offset; + + /* + * The invariants of UINT_SET guarantee a single list element if we have a + * single contiguous range, which is what we should have if everything has + * been acked. + */ + assert(r.end + 1 <= cur_size); + return r.start == 0 && r.end + 1 == cur_size; +} + void ossl_quic_sstream_adjust_iov(size_t len, OSSL_QTX_IOVEC *iov, size_t num_iov) |