aboutsummaryrefslogtreecommitdiffstats
path: root/util/timer.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2018-04-29 21:43:39 +0100
committerMatthew Wild <mwild1@gmail.com>2018-04-29 21:43:39 +0100
commitec22a5c10db7898508a3c9516088921d1782bfb2 (patch)
treeed7e870075dc2c987086a45e00f72df64a65a558 /util/timer.lua
parenta606a2f7e3f990f8e99ce28ab22ef9cd6830839c (diff)
downloadprosody-ec22a5c10db7898508a3c9516088921d1782bfb2.tar.gz
prosody-ec22a5c10db7898508a3c9516088921d1782bfb2.zip
util.timer: Ensure we don't try to schedule negative timeouts (which rightly upset libevent). Fixes #1135
Diffstat (limited to 'util/timer.lua')
-rw-r--r--util/timer.lua3
1 files changed, 2 insertions, 1 deletions
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;