net.server_epoll: Make maximum wait time configurable
authorKim Alvefur <zash@zash.se>
Mon, 22 Aug 2016 17:12:58 +0200
changeset 7626 a1c040a5754f
parent 7625 96e6df712359
child 7627 23fb3a084956
net.server_epoll: Make maximum wait time configurable
net/server_epoll.lua
--- a/net/server_epoll.lua	Sat Aug 20 19:12:19 2016 +0200
+++ b/net/server_epoll.lua	Mon Aug 22 17:12:58 2016 +0200
@@ -34,6 +34,7 @@
 	read_retry_delay = 1e-06;
 	connect_timeout = 20;
 	handshake_timeout = 60;
+	max_wait = 86400;
 };
 
 local fds = createtable(10, 0); -- FD -> conn
@@ -63,7 +64,7 @@
 
 -- Run callbacks of expired timers
 -- Return time until next timeout
-local function runtimers()
+local function runtimers(next_delay)
 	if resort_timers then
 		-- Sort earliest timers to the end
 		t_sort(timers, function (a, b) return a[1] > b[1]; end);
@@ -80,8 +81,6 @@
 	end
 	--]]
 
-	local next_delay = 86400;
-
 	-- Iterate from the end and remove completed timers
 	for i = #timers, 1, -1 do
 		local timer = timers[i];
@@ -579,7 +578,7 @@
 
 local function loop()
 	repeat
-		local t = runtimers();
+		local t = runtimers(cfg.max_wait);
 		local fd, r, w = epoll.wait(t);
 		if fd then
 			local conn = fds[fd];