diff options
author | Hugo Landau <hlandau@openssl.org> | 2024-03-28 08:58:50 +0000 |
---|---|---|
committer | Tomas Mraz <tomas@openssl.org> | 2024-04-10 15:50:44 +0200 |
commit | fa10ff62270a9f2209c5786225274ca35155ae02 (patch) | |
tree | 5fb513bf6a1ed2789e59580729bc157bea4a7eff | |
parent | 249a7135d0c91f0aa7051e5a066731fafe387e1a (diff) |
QUIC QSM: Add function to determine if data is waiting
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/24039)
-rw-r--r-- | include/internal/quic_stream_map.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/include/internal/quic_stream_map.h b/include/internal/quic_stream_map.h index ae7490619b..30ae1e5f98 100644 --- a/include/internal/quic_stream_map.h +++ b/include/internal/quic_stream_map.h @@ -504,6 +504,40 @@ static ossl_inline ossl_unused int ossl_quic_stream_recv_get_final_size(const QU } /* + * Determines the number of bytes available still to be read, and whether a FIN + * has yet to be read. + */ +static ossl_inline ossl_unused int ossl_quic_stream_recv_pending(const QUIC_STREAM *s) +{ + size_t avail; + int fin = 0; + + switch (s->recv_state) { + default: + case QUIC_RSTREAM_STATE_NONE: + return 0; + + case QUIC_RSTREAM_STATE_RECV: + case QUIC_RSTREAM_STATE_SIZE_KNOWN: + case QUIC_RSTREAM_STATE_DATA_RECVD: + if (!ossl_quic_rstream_available(s->rstream, &avail, &fin)) + avail = 0; + + if (avail == 0 && fin) + avail = 1; + + return avail; + + case QUIC_RSTREAM_STATE_RESET_RECVD: + return 1; + + case QUIC_RSTREAM_STATE_DATA_READ: + case QUIC_RSTREAM_STATE_RESET_READ: + return 0; + } +} + +/* * QUIC Stream Map * =============== * |