aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2016-08-12 00:25:19 +0200
committerKim Alvefur <zash@zash.se>2016-08-12 00:25:19 +0200
commita590be3b188d3d27ae7cd434a74ccf258a635e21 (patch)
tree5e8021daf0b3b52f8f237f5dee27112c2adc22a0 /net
parent51aabf600add1fbb81a41452a29383663c98702f (diff)
downloadprosody-a590be3b188d3d27ae7cd434a74ccf258a635e21.tar.gz
prosody-a590be3b188d3d27ae7cd434a74ccf258a635e21.zip
net.server_epoll: Fix calculation of next timer event
Diffstat (limited to 'net')
-rw-r--r--net/server_epoll.lua16
1 files changed, 7 insertions, 9 deletions
diff --git a/net/server_epoll.lua b/net/server_epoll.lua
index 100d3340..c6778e2b 100644
--- a/net/server_epoll.lua
+++ b/net/server_epoll.lua
@@ -79,24 +79,22 @@ local function runtimers()
if diff < next_delay then
next_delay = diff;
end
- return next_delay;
+ break;
end
local new_timeout = f(now);
if new_timeout then
- local t_diff = t + new_timeout - now;
- if t_diff < 1e-6 then
- t_diff = 1e-6;
- end
- if t_diff < next_delay then
- next_delay = t_diff;
- end
timer[1] = t + new_timeout;
resort_timers = true;
else
t_remove(timers, i);
end
end
- if next_delay < 1e-6 then
+ if resort_timers or next_delay < 1e-6 then
+ -- Timers may be added from within a timer callback.
+ -- Those would not be considered for next_dela,
+ -- and we might sleep for too long, so instead
+ -- we return a shorter timeout so we can
+ -- properly sort all new timers.
next_delay = 1e-6;
end
return next_delay;