Changeset

11811:ae43166fe931 0.11

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.
author Kim Alvefur <zash@zash.se>
date Mon, 20 Sep 2021 14:38:08 +0200 (2021-09-20)
parents 11810:fe0cdbad19c3
children 11812:42e98179c034 11825:07a72f0a32df
files net/server_epoll.lua
diffstat 1 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/net/server_epoll.lua	Mon Sep 20 14:42:18 2021 +0200
+++ b/net/server_epoll.lua	Mon Sep 20 14:38:08 2021 +0200
@@ -58,6 +58,9 @@
 	-- 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 @@
 				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