aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2023-01-06 04:38:39 +0100
committerKim Alvefur <zash@zash.se>2023-01-06 04:38:39 +0100
commitf5006b12024db1c76601cfe69960788a254c2b26 (patch)
tree660b015d01f4eabc2b336996c9c68e8275ef6b95 /net
parent5acb354989a2474feed3d83446c098cf6b4ea311 (diff)
downloadprosody-f5006b12024db1c76601cfe69960788a254c2b26.tar.gz
prosody-f5006b12024db1c76601cfe69960788a254c2b26.zip
net.server_epoll: Remove delay on last main loop iteration when quitting
Main difference is that timers are not checked unconditionally before each poll, only when running out of previous poll results (hidden by util.poll). This removes a final poll at shutdown that usually delays the 'not quitting' condition check by one second.
Diffstat (limited to 'net')
-rw-r--r--net/server_epoll.lua15
1 files changed, 8 insertions, 7 deletions
diff --git a/net/server_epoll.lua b/net/server_epoll.lua
index 66a60b5e..c7ab0c13 100644
--- a/net/server_epoll.lua
+++ b/net/server_epoll.lua
@@ -1109,10 +1109,11 @@ local function loop(once)
return loop_once();
end
- repeat
- local t = runtimers(cfg.max_wait, cfg.min_wait);
+ local t = 0;
+ while not quitting do
local fd, r, w = poll:wait(t);
- while fd do
+ if fd then
+ t = 0;
local conn = fds[fd];
if conn then
if r then
@@ -1125,12 +1126,12 @@ local function loop(once)
log("debug", "Removing unknown fd %d", fd);
poll:del(fd);
end
- fd, r, w = poll:wait(0);
- end
- if r ~= "timeout" and r ~= "signal" then
+ elseif r == "timeout" then
+ t = runtimers(cfg.max_wait, cfg.min_wait);
+ elseif r ~= "signal" then
log("debug", "epoll_wait error: %s[%d]", r, w);
end
- until (quitting and next(fds) == nil);
+ end
return quitting;
end