From 8a71020fbdad464f902138d5c07e886251d900ca Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Mon, 7 Oct 2024 00:14:23 -0700 Subject: Fix case for infinite sleep. If one tries to sleep indefinitely, a sign bug leads to constantly waking calls, which causes an infinite cycle in the expire loop. --- src/core/aio.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/core/aio.c b/src/core/aio.c index 27ec6d9c..1c7e41d1 100644 --- a/src/core/aio.c +++ b/src/core/aio.c @@ -755,12 +755,13 @@ nni_sleep_aio(nng_duration ms, nng_aio *aio) default: // If the timeout on the aio is shorter than our sleep time, // then let it still wake up early, but with NNG_ETIMEDOUT. - if (ms > aio->a_timeout) { + if ((ms == NNG_DURATION_INFINITE) || (ms > aio->a_timeout)) { aio->a_expire_ok = false; ms = aio->a_timeout; } } - aio->a_expire = nni_clock() + ms; + aio->a_expire = + ms == NNG_DURATION_INFINITE ? NNI_TIME_NEVER : nni_clock() + ms; if ((rv = nni_aio_schedule(aio, nni_sleep_cancel, NULL)) != 0) { nni_aio_finish_error(aio, rv); -- cgit v1.2.3-70-g09d2