mirror of
https://github.com/bjc/prosody.git
synced 2025-04-03 21:27:38 +03:00
mod_c2s,mod_s2s: Disable and close port listeners before closing sessions
This ensures no new clients can start connecting during shutdown
This commit is contained in:
parent
89f110bbf2
commit
f56aaf1ba1
3 changed files with 15 additions and 0 deletions
|
@ -48,6 +48,7 @@ files["plugins/"] = {
|
||||||
"module.saved_state",
|
"module.saved_state",
|
||||||
"module.global",
|
"module.global",
|
||||||
"module.path",
|
"module.path",
|
||||||
|
"module.items",
|
||||||
|
|
||||||
-- Module API
|
-- Module API
|
||||||
"module.add_extension",
|
"module.add_extension",
|
||||||
|
|
|
@ -423,6 +423,13 @@ end
|
||||||
module:hook("c2s-read-timeout", keepalive, -1);
|
module:hook("c2s-read-timeout", keepalive, -1);
|
||||||
|
|
||||||
module:hook("server-stopping", function(event)
|
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;
|
local reason = event.reason;
|
||||||
for _, session in pairs(sessions) do
|
for _, session in pairs(sessions) do
|
||||||
session:close{ condition = "system-shutdown", text = reason };
|
session:close{ condition = "system-shutdown", text = reason };
|
||||||
|
|
|
@ -958,6 +958,13 @@ end
|
||||||
module:hook("s2s-check-certificate", check_auth_policy, -1);
|
module:hook("s2s-check-certificate", check_auth_policy, -1);
|
||||||
|
|
||||||
module:hook("server-stopping", function(event)
|
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;
|
local reason = event.reason;
|
||||||
for _, session in pairs(sessions) do
|
for _, session in pairs(sessions) do
|
||||||
session:close{ condition = "system-shutdown", text = reason };
|
session:close{ condition = "system-shutdown", text = reason };
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue