aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2015-12-23 11:43:39 +0100
committerKim Alvefur <zash@zash.se>2015-12-23 11:43:39 +0100
commitb3d8c070f940572d53e8bea734a7abef38411c56 (patch)
treefe6e50f39ad51a36a21d6caaaf906388e622f437 /util
parent9e88c5e954dc3d55b69060039cbcb60a677e76e9 (diff)
downloadprosody-b3d8c070f940572d53e8bea734a7abef38411c56.tar.gz
prosody-b3d8c070f940572d53e8bea734a7abef38411c56.zip
util.timer: Reschedule timers from stop() if the next pending event is stopped
Diffstat (limited to 'util')
-rw-r--r--util/timer.lua11
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();