From d4555a6e38b2e8fb5d5ba0fe683e283c1e1197fd Mon Sep 17 00:00:00 2001 From: John Sully Date: Tue, 18 Oct 2022 00:28:32 +0000 Subject: [PATCH] We need to check for AE_DONT_WAIT after it is set in beforeSleep otherwise we'll miss it --- src/ae.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ae.cpp b/src/ae.cpp index 702c465d4..9d8c945d5 100644 --- a/src/ae.cpp +++ b/src/ae.cpp @@ -716,11 +716,6 @@ int aeProcessEvents(aeEventLoop *eventLoop, int flags) } } - if (eventLoop->flags & AE_DONT_WAIT) { - tv.tv_sec = tv.tv_usec = 0; - tvp = &tv; - } - if (eventLoop->beforesleep != NULL && flags & AE_CALL_BEFORE_SLEEP) { std::unique_lock ulock(g_lock, std::defer_lock); if (!(eventLoop->beforesleepFlags & AE_SLEEP_THREADSAFE)) { @@ -731,6 +726,11 @@ int aeProcessEvents(aeEventLoop *eventLoop, int flags) eventLoop->beforesleep(eventLoop); } + if (eventLoop->flags & AE_DONT_WAIT) { + tv.tv_sec = tv.tv_usec = 0; + tvp = &tv; + } + /* Call the multiplexing API, will return only on timeout or when * some event fires. */ numevents = aeApiPoll(eventLoop, tvp);