diff options
author | Matthew Wild <mwild1@gmail.com> | 2018-04-29 21:43:39 +0100 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2018-04-29 21:43:39 +0100 |
commit | ec22a5c10db7898508a3c9516088921d1782bfb2 (patch) | |
tree | ed7e870075dc2c987086a45e00f72df64a65a558 /util/timer.lua | |
parent | a606a2f7e3f990f8e99ce28ab22ef9cd6830839c (diff) | |
download | prosody-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.lua | 3 |
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; |