# HG changeset patch # User Kim Alvefur # Date 1450867419 -3600 # Node ID 17e275e8bd79d31ea1bc651b8c47a6a67f684a07 # Parent 298bfc7688891c9a2fba3abd0849d48790a00bce util.timer: Reschedule timers from stop() if the next pending event is stopped diff -r 298bfc768889 -r 17e275e8bd79 util/timer.lua --- 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();