Comparison

plugins/mod_s2s.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 12280:74f8739b967a
child 12299:ff36ac5c7d2b
comparison
equal deleted inserted replaced
12297:249eb306f668 12298:cb459f8fa740
956 end 956 end
957 957
958 module:hook("s2s-check-certificate", check_auth_policy, -1); 958 module:hook("s2s-check-certificate", check_auth_policy, -1);
959 959
960 module:hook("server-stopping", function(event) 960 module:hook("server-stopping", function(event)
961 -- Close ports
962 local pm = require "core.portmanager";
963 for _, netservice in pairs(module.items["net-provider"]) do
964 pm.unregister_service(netservice.name, netservice);
965 end
966
967 -- Close sessions
961 local reason = event.reason; 968 local reason = event.reason;
962 for _, session in pairs(sessions) do 969 for _, session in pairs(sessions) do
963 session:close{ condition = "system-shutdown", text = reason }; 970 session:close{ condition = "system-shutdown", text = reason };
964 end 971 end
965 end, -200); 972 end, -200);