Skip to content

Commit

Permalink
Change approach to SSL_pending API
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 c4d15e0 commit 7acd04d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
11 changes: 6 additions & 5 deletions include/internal/quic_stream_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -504,10 +504,11 @@ 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.
* Determines the number of bytes available still to be read, and (if
* include_fin is 1) whether a FIN or reset has yet to be read.
*/
static ossl_inline ossl_unused int ossl_quic_stream_recv_pending(const QUIC_STREAM *s)
static ossl_inline ossl_unused int ossl_quic_stream_recv_pending(const QUIC_STREAM *s,
int include_fin)
{
size_t avail;
int fin = 0;
Expand All @@ -523,13 +524,13 @@ static ossl_inline ossl_unused int ossl_quic_stream_recv_pending(const QUIC_STRE
if (!ossl_quic_rstream_available(s->rstream, &avail, &fin))
avail = 0;

if (avail == 0 && fin)
if (avail == 0 && include_fin && fin)
avail = 1;

return avail;

case QUIC_RSTREAM_STATE_RESET_RECVD:
return 1;
return include_fin;

case QUIC_RSTREAM_STATE_DATA_READ:
case QUIC_RSTREAM_STATE_RESET_READ:
Expand Down
6 changes: 4 additions & 2 deletions ssl/quic/quic_impl.c
Original file line number Diff line number Diff line change
Expand Up @@ -2986,11 +2986,13 @@ static size_t ossl_quic_pending_int(const SSL *s, int check_channel)
}

if (check_channel)
avail = ossl_quic_stream_recv_pending(ctx.xso->stream)
avail = ossl_quic_stream_recv_pending(ctx.xso->stream,
/*include_fin=*/1)
|| ossl_quic_channel_has_pending(ctx.qc->ch)
|| ossl_quic_channel_is_term_any(ctx.qc->ch);
else
avail = ossl_quic_stream_recv_pending(ctx.xso->stream);
avail = ossl_quic_stream_recv_pending(ctx.xso->stream,
/*include_fin=*/0);

out:
qctx_unlock(&ctx);
Expand Down

0 comments on commit 7acd04d

Please sign in to comment.