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);