diff options
author | Kim Alvefur <zash@zash.se> | 2018-10-28 18:22:17 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2018-10-28 18:22:17 +0100 |
commit | 81a8dca01e7df9f7dbf7478ccac4ada001a88b6d (patch) | |
tree | 0a1322875b1c6b21c1ff5d9161a5422c05d51355 /net | |
parent | 5d8bd2a789a52a5c927bc9a8a97c941870437fdd (diff) | |
download | prosody-81a8dca01e7df9f7dbf7478ccac4ada001a88b6d.tar.gz prosody-81a8dca01e7df9f7dbf7478ccac4ada001a88b6d.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.lua | 10 |
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); |