summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHugo Landau <hlandau@openssl.org>2024-04-04 12:03:49 +0100
committerHugo Landau <hlandau@openssl.org>2024-04-19 09:33:53 +0100
commit0fb05d699e2827895df5787c776402edd56f1383 (patch)
treedd80a6e1efc38c0e2aa1c17d9d8e452fd78f6470
parent17ff3b8ebe439f461945d9aecf6018f4db51bda5 (diff)
QUIC REACTOR: Ensure no assertion failure or deadlock if called when unable to wait
Reviewed-by: Neil Horman <nhorman@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/24037)
-rw-r--r--ssl/quic/quic_reactor.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/ssl/quic/quic_reactor.c b/ssl/quic/quic_reactor.c
index 3975b87717..abb6b1f50e 100644
--- a/ssl/quic/quic_reactor.c
+++ b/ssl/quic/quic_reactor.c
@@ -348,7 +348,8 @@ int ossl_quic_reactor_block_until_pred(QUIC_REACTOR *rtor,
uint32_t flags,
CRYPTO_MUTEX *mutex)
{
- int res;
+ int res, net_read_desired, net_write_desired;
+ OSSL_TIME tick_deadline;
for (;;) {
if ((flags & SKIP_FIRST_TICK) != 0)
@@ -360,11 +361,19 @@ int ossl_quic_reactor_block_until_pred(QUIC_REACTOR *rtor,
if ((res = pred(pred_arg)) != 0)
return res;
+ net_read_desired = ossl_quic_reactor_net_read_desired(rtor);
+ net_write_desired = ossl_quic_reactor_net_write_desired(rtor);
+ tick_deadline = ossl_quic_reactor_get_tick_deadline(rtor);
+ if (!net_read_desired && !net_write_desired
+ && ossl_time_is_infinite(tick_deadline))
+ /* Can't wait if there is nothing to wait for. */
+ return 0;
+
if (!poll_two_descriptors(ossl_quic_reactor_get_poll_r(rtor),
- ossl_quic_reactor_net_read_desired(rtor),
+ net_read_desired,
ossl_quic_reactor_get_poll_w(rtor),
- ossl_quic_reactor_net_write_desired(rtor),
- ossl_quic_reactor_get_tick_deadline(rtor),
+ net_write_desired,
+ tick_deadline,
mutex))
/*
* We don't actually care why the call succeeded (timeout, FD