aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2021-09-20 14:38:08 +0200
committerKim Alvefur <zash@zash.se>2021-09-20 14:38:08 +0200
commit24111569bb5b75ea37cbf2c29d49d88206365ae2 (patch)
tree69f891a538388879c9fc93567c43c502336180c3
parent6d5ff6d2be030b9ab133867eca04200923a42fdb (diff)
downloadprosody-24111569bb5b75ea37cbf2c29d49d88206365ae2.tar.gz
prosody-24111569bb5b75ea37cbf2c29d49d88206365ae2.zip
net.server_epoll: Add a hard deadline on shutdown to extra-fix #1670
Should ensure shutdown even if sockets somehow take a very long to get closed.
-rw-r--r--net/server_epoll.lua12
1 files changed, 12 insertions, 0 deletions
diff --git a/net/server_epoll.lua b/net/server_epoll.lua
index ae9808ad..c47e1a70 100644
--- a/net/server_epoll.lua
+++ b/net/server_epoll.lua
@@ -58,6 +58,9 @@ local default_config = { __index = {
-- Maximum and minimum amount of time to sleep waiting for events (adjusted for pending timers)
max_wait = 86400;
min_wait = 1e-06;
+
+ --- How long to wait after getting the shutdown signal before forcefully tearing down every socket
+ shutdown_deadline = 5;
}};
local cfg = default_config.__index;
@@ -749,6 +752,15 @@ local function setquitting(quit)
return 1;
end
end);
+ if cfg.shutdown_deadline then
+ addtimer(cfg.shutdown_deadline, function ()
+ if quitting then
+ for fd, conn in pairs(fds) do -- luacheck: ignore 213/fd
+ conn:destroy();
+ end
+ end
+ end);
+ end
else
quitting = nil;
end