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 | 9f9b1f9fda0bcd74248b5b98a2e965f120bd7026 (patch) | |
tree | ed7e870075dc2c987086a45e00f72df64a65a558 /util | |
parent | 265e698cd07f7ee508a741200870a3e79d47b2e7 (diff) | |
download | prosody-9f9b1f9fda0bcd74248b5b98a2e965f120bd7026.tar.gz prosody-9f9b1f9fda0bcd74248b5b98a2e965f120bd7026.zip |
util.timer: Ensure we don't try to schedule negative timeouts (which rightly upset libevent). Fixes #1135
Diffstat (limited to 'util')
-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; |