Diff

net/server_epoll.lua @ 10982:276f16101d59

net.server_epoll: Make API-compatible with util.timer
author Kim Alvefur <zash@zash.se>
date Mon, 29 Jun 2020 16:42:16 +0200
parent 10861:e12690a37795
child 10983:0862325842ec
line wrap: on
line diff
--- a/net/server_epoll.lua	Mon Jun 29 16:37:58 2020 +0200
+++ b/net/server_epoll.lua	Mon Jun 29 16:42:16 2020 +0200
@@ -99,9 +99,9 @@
 end
 
 -- Add relative timer
-local function addtimer(timeout, f)
+local function addtimer(timeout, f, param)
 	local time = monotonic() + timeout;
-	local timer = { time, f, close = closetimer, reschedule = reschedule, id = nil };
+	local timer = { time, f, param, close = closetimer, reschedule = reschedule, id = nil };
 	timer.id = timers:insert(timer, time);
 	return timer;
 end
@@ -121,7 +121,7 @@
 		end
 
 		local _, timer = timers:pop();
-		local ok, ret = pcall(timer[2], now);
+		local ok, ret = pcall(timer[2], now, timer, timer[3]);
 		if ok and type(ret) == "number"  then
 			local next_time = elapsed+ret;
 			timer[1] = next_time;