diff options
| author | Garrett D'Amore <garrett@damore.org> | 2024-10-07 00:14:23 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2024-10-07 00:14:23 -0700 |
| commit | 8a71020fbdad464f902138d5c07e886251d900ca (patch) | |
| tree | 928d91db08ae888b29b68b1fe51c1b6a78383fe7 | |
| parent | 2dfb99506142f2d59bcc0e0fa7db6b19a3c75d43 (diff) | |
| download | nng-8a71020fbdad464f902138d5c07e886251d900ca.tar.gz nng-8a71020fbdad464f902138d5c07e886251d900ca.tar.bz2 nng-8a71020fbdad464f902138d5c07e886251d900ca.zip | |
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.
| -rw-r--r-- | src/core/aio.c | 5 |
1 files 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); |
