aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2016-09-04 17:17:22 +0200
committerKim Alvefur <zash@zash.se>2016-09-04 17:17:22 +0200
commitaaefe2e6ed4c9d2cf217a3b6f627e75be3b3f446 (patch)
treeaa6a0cb58a1eb4b780cb9c16cb6248f2e399dc44
parent54332813ba253295b2bb616602a188994f32e46a (diff)
downloadprosody-aaefe2e6ed4c9d2cf217a3b6f627e75be3b3f446.tar.gz
prosody-aaefe2e6ed4c9d2cf217a3b6f627e75be3b3f446.zip
net.server_epoll: Make minimum poll wait time configurable
-rw-r--r--net/server_epoll.lua11
1 files changed, 7 insertions, 4 deletions
diff --git a/net/server_epoll.lua b/net/server_epoll.lua
index 0513e315..9ef14a78 100644
--- a/net/server_epoll.lua
+++ b/net/server_epoll.lua
@@ -35,6 +35,7 @@ local default_config = { __index = {
connect_timeout = 20;
handshake_timeout = 60;
max_wait = 86400;
+ min_wait = 1e-06;
}};
local cfg = default_config.__index;
@@ -68,7 +69,7 @@ end
-- Run callbacks of expired timers
-- Return time until next timeout
-local function runtimers(next_delay)
+local function runtimers(next_delay, min_wait)
-- Any timers at all?
if not timers[1] then
return next_delay;
@@ -104,14 +105,16 @@ local function runtimers(next_delay)
t_remove(timers, i);
end
end
- if resort_timers or next_delay < 1e-6 then
+
+ if resort_timers or next_delay < min_wait then
-- Timers may be added from within a timer callback.
-- Those would not be considered for next_delay,
-- 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;
+ next_delay = min_wait;
end
+
return next_delay;
end
@@ -602,7 +605,7 @@ end
-- Main loop
local function loop()
repeat
- local t = runtimers(cfg.max_wait);
+ local t = runtimers(cfg.max_wait, cfg.min_wait);
local fd, r, w = epoll.wait(t);
if fd then
local conn = fds[fd];