# HG changeset patch # User Kim Alvefur # Date 1473002242 -7200 # Node ID e14a124c4d731546d594eaa5d429e779713a74c5 # Parent 2528236324011837d08d3169c0f01e4f371cfbe4 net.server_epoll: Make minimum poll wait time configurable diff -r 252823632401 -r e14a124c4d73 net/server_epoll.lua --- a/net/server_epoll.lua Sun Sep 04 17:16:46 2016 +0200 +++ b/net/server_epoll.lua Sun Sep 04 17:17:22 2016 +0200 @@ -35,6 +35,7 @@ connect_timeout = 20; handshake_timeout = 60; max_wait = 86400; + min_wait = 1e-06; }}; local cfg = default_config.__index; @@ -68,7 +69,7 @@ -- 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 @@ 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 @@ -- 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];