From c8e2129a82d666571b48232f39bfae30a0470db2 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Tue, 21 Nov 2023 17:43:46 +0100 Subject: util.poll: Return early if given zero timeout and no pending events Should have been part of f33887f925e1 to ensure it won't skip processing timers at all when very busy. --- util-src/poll.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'util-src') diff --git a/util-src/poll.c b/util-src/poll.c index 6ec9ae35..d3d7640f 100644 --- a/util-src/poll.c +++ b/util-src/poll.c @@ -411,6 +411,12 @@ static int Lwait(lua_State *L) { lua_Number timeout = luaL_checknumber(L, 2); luaL_argcheck(L, timeout >= 0, 1, "positive number expected"); + if(timeout == 0.0) { + lua_pushnil(L); + lua_pushstring(L, "timeout"); + return 2; + } + #ifdef USE_EPOLL ret = epoll_wait(state->epoll_fd, state->events, MAX_EVENTS, timeout * 1000); #endif -- cgit v1.2.3