Changeset

7624:23fb3a084956

net.server_epoll: Comments
author Kim Alvefur <zash@zash.se>
date Mon, 22 Aug 2016 17:13:39 +0200
parents 7623:a1c040a5754f
children 7625:6afafd6d4ef0
files net/server_epoll.lua
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/net/server_epoll.lua	Mon Aug 22 17:12:58 2016 +0200
+++ b/net/server_epoll.lua	Mon Aug 22 17:13:39 2016 +0200
@@ -85,7 +85,8 @@
 	for i = #timers, 1, -1 do
 		local timer = timers[i];
 		local t, f = timer[1], timer[2];
-		local now = gettime(); -- inside or before the loop?
+		-- Get time for every iteration to increase accuracy
+		local now = gettime();
 		if t > now then
 			-- This timer should not fire yet
 			local diff = t - now;
@@ -96,6 +97,8 @@
 		end
 		local new_timeout = f(now);
 		if new_timeout then
+			-- Schedlue for 'delay' from the time actually sheduled,
+			-- not from now, in order to prevent timer drift.
 			timer[1] = t + new_timeout;
 			resort_timers = true;
 		else
@@ -487,6 +490,7 @@
 	self:setflags(true);
 end
 
+-- Pause connection for some time
 function interface:pausefor(t)
 	if self._pausefor then
 		self._pausefor:close();