Diff

plugins/mod_c2s.lua @ 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
parent 12071:85c8fcb4192e
child 12300:fb74ff16620c
line wrap: on
line diff
--- 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 };