aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2023-11-21 17:43:46 +0100
committerKim Alvefur <zash@zash.se>2023-11-21 17:43:46 +0100
commitc8e2129a82d666571b48232f39bfae30a0470db2 (patch)
treec7badd20561a0d187bba4ebc371e3a6be13724c2
parent43d1285dbd6914b497d6c7684160d9dd57b97120 (diff)
downloadprosody-c8e2129a82d666571b48232f39bfae30a0470db2.tar.gz
prosody-c8e2129a82d666571b48232f39bfae30a0470db2.zip
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.
-rw-r--r--util-src/poll.c6
1 files changed, 6 insertions, 0 deletions
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