aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2022-02-11 21:36:53 +0100
committerKim Alvefur <zash@zash.se>2022-02-11 21:36:53 +0100
commitf56aaf1ba149176fe65254960cba957843c4ca10 (patch)
treeabd9cf32d53f02601866cc7c8be273692deadf98 /plugins
parent89f110bbf20dd54c438ea0bce274860cee75606c (diff)
downloadprosody-f56aaf1ba149176fe65254960cba957843c4ca10.tar.gz
prosody-f56aaf1ba149176fe65254960cba957843c4ca10.zip
mod_c2s,mod_s2s: Disable and close port listeners before closing sessions
This ensures no new clients can start connecting during shutdown
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mod_c2s.lua7
-rw-r--r--plugins/mod_s2s.lua7
2 files changed, 14 insertions, 0 deletions
diff --git a/plugins/mod_c2s.lua b/plugins/mod_c2s.lua
index c9aae3bc..7c5c4182 100644
--- a/plugins/mod_c2s.lua
+++ b/plugins/mod_c2s.lua
@@ -423,6 +423,13 @@ end
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 };
diff --git a/plugins/mod_s2s.lua b/plugins/mod_s2s.lua
index 3710a967..1b40f782 100644
--- a/plugins/mod_s2s.lua
+++ b/plugins/mod_s2s.lua
@@ -958,6 +958,13 @@ end
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 };