Changeset

13329:649876680bf0

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.
author Kim Alvefur <zash@zash.se>
date Tue, 21 Nov 2023 17:43:46 +0100
parents 13328:36284c879e2f
children 13330:49ecfb070240
files util-src/poll.c
diffstat 1 files changed, 6 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/util-src/poll.c	Mon Nov 13 10:40:24 2023 +0100
+++ b/util-src/poll.c	Tue Nov 21 17:43:46 2023 +0100
@@ -411,6 +411,12 @@
 	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