Diff

util-src/poll.c @ 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
parent 12976:a187600ec7d6
child 13335:8b3bf0d2ffd4
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