aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2021-01-08 23:56:27 +0100
committerKim Alvefur <zash@zash.se>2021-01-08 23:56:27 +0100
commit2f4d12286f17da4e0a1d6916e9c6addd5f61f9f5 (patch)
treeae3423f96ff891efa62da56d3223f2824ccffd2c /net
parentcb1282bfd0959b52c0725e2249c07c9319b58da0 (diff)
parent365e5b0cb481315525d4f2bfbf478340b8dc08d8 (diff)
downloadprosody-2f4d12286f17da4e0a1d6916e9c6addd5f61f9f5.tar.gz
prosody-2f4d12286f17da4e0a1d6916e9c6addd5f61f9f5.zip
Merge 0.11->trunk
Diffstat (limited to 'net')
-rw-r--r--net/server_epoll.lua20
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