diff options
author | Kim Alvefur <zash@zash.se> | 2015-12-23 11:43:39 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2015-12-23 11:43:39 +0100 |
commit | 9cf26570d1ed58175107e606a044506e5210f501 (patch) | |
tree | fe6e50f39ad51a36a21d6caaaf906388e622f437 /util | |
parent | 9a33b25f7024bf0d89e1c74e0e7bff78ab486464 (diff) | |
download | prosody-9cf26570d1ed58175107e606a044506e5210f501.tar.gz prosody-9cf26570d1ed58175107e606a044506e5210f501.zip |
util.timer: Reschedule timers from stop() if the next pending event is stopped
Diffstat (limited to 'util')
-rw-r--r-- | util/timer.lua | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/util/timer.lua b/util/timer.lua index eb2bd7ea..2277ee77 100644 --- a/util/timer.lua +++ b/util/timer.lua @@ -79,7 +79,16 @@ local function add_task(delay, callback, param) end local function stop(id) params[id] = nil; - return h:remove(id); + local result, item, result_sync = h:remove(id); + local peek = h:peek(); + if peek ~= next_time and _server_timer then + next_time = peek; + _server_timer:close(); + if next_time ~= nil then + _server_timer = _add_task(next_time - get_time(), _on_timer); + end + end + return result, item, result_sync; end local function reschedule(id, delay) local current_time = get_time(); |