Skip to content

Commit

Permalink
QUIC QSM: Add function to determine if data is waiting
Browse files Browse the repository at this point in the history
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #23995)
  • Loading branch information
hlandau authored and t8m committed Apr 4, 2024
1 parent f202a68 commit b7c960e
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions include/internal/quic_stream_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,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
* ===============
Expand Down

0 comments on commit b7c960e

Please sign in to comment.