aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2018-10-28 18:22:17 +0100
committerKim Alvefur <zash@zash.se>2018-10-28 18:22:17 +0100
commit1f9b825c34e068f951cf4154ceb71580aea23eb0 (patch)
tree0a1322875b1c6b21c1ff5d9161a5422c05d51355 /net
parent9d6cefcaeb41c6a4257a103c3f1745a7d1b10397 (diff)
downloadprosody-1f9b825c34e068f951cf4154ceb71580aea23eb0.tar.gz
prosody-1f9b825c34e068f951cf4154ceb71580aea23eb0.zip
net.server_epoll: Reschedule delayed timers relative to current time
This should normally never happen, but can be reproduced by suspending the process a while.
Diffstat (limited to 'net')
-rw-r--r--net/server_epoll.lua10
1 files changed, 7 insertions, 3 deletions
diff --git a/net/server_epoll.lua b/net/server_epoll.lua
index cdf3e8fe..ce8996a8 100644
--- a/net/server_epoll.lua
+++ b/net/server_epoll.lua
@@ -106,9 +106,13 @@ local function runtimers(next_delay, min_wait)
end
local new_timeout = f(now);
if new_timeout then
- -- Schedule for 'delay' from the time actually scheduled,
- -- not from now, in order to prevent timer drift.
- timer[1] = t + new_timeout;
+ -- Schedule for 'delay' from the time actually scheduled, not from now,
+ -- in order to prevent timer drift, unless it already drifted way out of sync.
+ if (t + new_timeout) > ( now - new_timeout ) then
+ timer[1] = t + new_timeout;
+ else
+ timer[1] = now + new_timeout;
+ end
resort_timers = true;
else
t_remove(timers, i);