aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2015-11-22 17:20:20 +0100
committerKim Alvefur <zash@zash.se>2015-11-22 17:20:20 +0100
commit3df8a52d197a8fb2c51761950d8be7012ddd6141 (patch)
tree04087399e577bb0cf7d1d0a12f90038f80be1116 /util
parent45f9a387a2925a5bb835a7b7ff6ba6f0d401aec9 (diff)
downloadprosody-3df8a52d197a8fb2c51761950d8be7012ddd6141.tar.gz
prosody-3df8a52d197a8fb2c51761950d8be7012ddd6141.zip
util.timer: Expire timer instance if another instance is already set to take care of the next scheduled event
Diffstat (limited to 'util')
-rw-r--r--util/timer.lua13
1 files changed, 11 insertions, 2 deletions
diff --git a/util/timer.lua b/util/timer.lua
index 9042264d..78b4dbd7 100644
--- a/util/timer.lua
+++ b/util/timer.lua
@@ -43,8 +43,17 @@ local function _on_timer(now)
params[_id] = _param;
end
end
- next_time = peek;
- if peek ~= nil then
+
+ if peek ~= nil and _active_timers > 1 and peek == next_time then
+ -- Another instance of _on_timer already set next_time to the same value,
+ -- so it should be safe to not renew this timer event
+ peek = nil;
+ else
+ next_time = peek;
+ end
+
+ if peek then
+ -- peek is the time of the next event
return peek - now;
end
_active_timers = _active_timers - 1;