Diff

util/timer.lua @ 8762:2f8523bf7ff2

util.timer: Ensure we don't try to schedule negative timeouts (which rightly upset libevent). Fixes #1135
author Matthew Wild <mwild1@gmail.com>
date Sun, 29 Apr 2018 21:43:39 +0100
parent 8685:2548111e71d6
child 8995:2e6f7ab97794
line wrap: on
line diff
--- a/util/timer.lua	Wed Apr 25 11:55:03 2018 +0100
+++ b/util/timer.lua	Sun Apr 29 21:43:39 2018 +0100
@@ -15,6 +15,7 @@
 local debug_traceback = debug.traceback;
 local tostring = tostring;
 local xpcall = xpcall;
+local math_max = math.max;
 
 local _ENV = nil;
 -- luacheck: std none
@@ -87,7 +88,7 @@
 		next_time = peek;
 		_server_timer:close();
 		if next_time ~= nil then
-			_server_timer = _add_task(next_time - get_time(), _on_timer);
+			_server_timer = _add_task(math_max(next_time - get_time(), 0), _on_timer);
 		end
 	end
 	return result, item, result_sync;