Changeset

12298:cb459f8fa740

mod_c2s,mod_s2s: Disable and close port listeners before closing sessions This ensures no new clients can start connecting during shutdown
author Kim Alvefur <zash@zash.se>
date Fri, 11 Feb 2022 21:36:53 +0100
parents 12297:249eb306f668
children 12299:ff36ac5c7d2b
files .luacheckrc plugins/mod_c2s.lua plugins/mod_s2s.lua
diffstat 3 files changed, 15 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/.luacheckrc	Wed Oct 06 14:50:47 2021 +0200
+++ b/.luacheckrc	Fri Feb 11 21:36:53 2022 +0100
@@ -48,6 +48,7 @@
 		"module.saved_state",
 		"module.global",
 		"module.path",
+		"module.items",
 
 		-- Module API
 		"module.add_extension",
--- a/plugins/mod_c2s.lua	Wed Oct 06 14:50:47 2021 +0200
+++ b/plugins/mod_c2s.lua	Fri Feb 11 21:36:53 2022 +0100
@@ -423,6 +423,13 @@
 module:hook("c2s-read-timeout", keepalive, -1);
 
 module:hook("server-stopping", function(event)
+	-- Close ports
+	local pm = require "core.portmanager";
+	for _, netservice in pairs(module.items["net-provider"]) do
+		pm.unregister_service(netservice.name, netservice);
+	end
+
+	-- Close sessions
 	local reason = event.reason;
 	for _, session in pairs(sessions) do
 		session:close{ condition = "system-shutdown", text = reason };
--- a/plugins/mod_s2s.lua	Wed Oct 06 14:50:47 2021 +0200
+++ b/plugins/mod_s2s.lua	Fri Feb 11 21:36:53 2022 +0100
@@ -958,6 +958,13 @@
 module:hook("s2s-check-certificate", check_auth_policy, -1);
 
 module:hook("server-stopping", function(event)
+	-- Close ports
+	local pm = require "core.portmanager";
+	for _, netservice in pairs(module.items["net-provider"]) do
+		pm.unregister_service(netservice.name, netservice);
+	end
+
+	-- Close sessions
 	local reason = event.reason;
 	for _, session in pairs(sessions) do
 		session:close{ condition = "system-shutdown", text = reason };