From 9f9b1f9fda0bcd74248b5b98a2e965f120bd7026 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Sun, 29 Apr 2018 21:43:39 +0100 Subject: util.timer: Ensure we don't try to schedule negative timeouts (which rightly upset libevent). Fixes #1135 --- util/timer.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'util') diff --git a/util/timer.lua b/util/timer.lua index 70678ab2..424d44fa 100644 --- a/util/timer.lua +++ b/util/timer.lua @@ -15,6 +15,7 @@ local type = type; 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 @@ local function stop(id) 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; -- cgit v1.2.3