Software /
code /
prosody
Comparison
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 |
comparison
equal
deleted
inserted
replaced
12297:249eb306f668 | 12298:cb459f8fa740 |
---|---|
421 end | 421 end |
422 | 422 |
423 module:hook("c2s-read-timeout", keepalive, -1); | 423 module:hook("c2s-read-timeout", keepalive, -1); |
424 | 424 |
425 module:hook("server-stopping", function(event) | 425 module:hook("server-stopping", function(event) |
426 -- Close ports | |
427 local pm = require "core.portmanager"; | |
428 for _, netservice in pairs(module.items["net-provider"]) do | |
429 pm.unregister_service(netservice.name, netservice); | |
430 end | |
431 | |
432 -- Close sessions | |
426 local reason = event.reason; | 433 local reason = event.reason; |
427 for _, session in pairs(sessions) do | 434 for _, session in pairs(sessions) do |
428 session:close{ condition = "system-shutdown", text = reason }; | 435 session:close{ condition = "system-shutdown", text = reason }; |
429 end | 436 end |
430 end, -100); | 437 end, -100); |