Software /
code /
prosody
Changeset
7015:17e275e8bd79
util.timer: Reschedule timers from stop() if the next pending event is stopped
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 23 Dec 2015 11:43:39 +0100 |
parents | 7014:298bfc768889 |
children | 7036:f26debcae34e |
files | util/timer.lua |
diffstat | 1 files changed, 10 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/util/timer.lua Wed Dec 23 11:42:14 2015 +0100 +++ b/util/timer.lua Wed Dec 23 11:43:39 2015 +0100 @@ -79,7 +79,16 @@ 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();