diff options
author | Kim Alvefur <zash@zash.se> | 2021-01-08 23:56:27 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2021-01-08 23:56:27 +0100 |
commit | f4dd4dd8b8318818724bd04b5ce47197e63f441a (patch) | |
tree | ae3423f96ff891efa62da56d3223f2824ccffd2c /net/server_epoll.lua | |
parent | b0a1bf86267a8731d5d7fc36a8c9b052db5f661f (diff) | |
parent | 4cb0cd912590e43417b8fdd93f23ead06c23d542 (diff) | |
download | prosody-f4dd4dd8b8318818724bd04b5ce47197e63f441a.tar.gz prosody-f4dd4dd8b8318818724bd04b5ce47197e63f441a.zip |
Merge 0.11->trunk
Diffstat (limited to 'net/server_epoll.lua')
-rw-r--r-- | net/server_epoll.lua | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/net/server_epoll.lua b/net/server_epoll.lua index 010d1ca9..b079bdd2 100644 --- a/net/server_epoll.lua +++ b/net/server_epoll.lua @@ -119,10 +119,10 @@ local function runtimers(next_delay, min_wait) local elapsed = monotonic(); local now = realtime(); local peek = timers:peek(); + local readd; while peek do if peek > elapsed then - next_delay = peek - elapsed; break; end @@ -130,15 +130,31 @@ local function runtimers(next_delay, min_wait) local ok, ret = xpcall(timer, traceback, now, id); if ok and type(ret) == "number" then local next_time = elapsed+ret; - timers:insert(timer, next_time); + -- Delay insertion of timers to be re-added + -- so they don't get called again this tick + if readd then + readd[id] = { timer, next_time }; + else + readd = { [id] = { timer, next_time } }; + end elseif not ok then log("error", "Error in timer: %s", ret); end peek = timers:peek(); end + + if readd then + for _, timer in pairs(readd) do + timers:insert(timer[1], timer[2]); + end + peek = timers:peek(); + end + if peek == nil then return next_delay; + else + next_delay = peek - elapsed; end if next_delay < min_wait then |