Comparison

plugins/mod_c2s.lua @ 12300:fb74ff16620c

mod_c2s: Close ports in a separate, earlier event from closing sessions Lets other things step in and do things while c2s ports are closed, e.g. mod_smacks, or other modules with port handlers that forward to c2s.
author Kim Alvefur <zash@zash.se>
date Fri, 18 Feb 2022 14:25:22 +0100
parent 12298:cb459f8fa740
child 12301:4f1fe6eb1ddb
comparison
equal deleted inserted replaced
12299:ff36ac5c7d2b 12300:fb74ff16620c
426 -- Close ports 426 -- Close ports
427 local pm = require "core.portmanager"; 427 local pm = require "core.portmanager";
428 for _, netservice in pairs(module.items["net-provider"]) do 428 for _, netservice in pairs(module.items["net-provider"]) do
429 pm.unregister_service(netservice.name, netservice); 429 pm.unregister_service(netservice.name, netservice);
430 end 430 end
431 431 end, -80);
432
433 module:hook("server-stopping", function(event)
432 -- Close sessions 434 -- Close sessions
433 local reason = event.reason; 435 local reason = event.reason;
434 for _, session in pairs(sessions) do 436 for _, session in pairs(sessions) do
435 session:close{ condition = "system-shutdown", text = reason }; 437 session:close{ condition = "system-shutdown", text = reason };
436 end 438 end