# HG changeset patch # User Marco Cirillo # Date 1340666769 0 # Node ID f79fda2d7e517e2da05ed4f72c5da0c5fe732ba0 # Parent b94010de43f617f1633a5f4c7538749d9e246451 mod_host_guard: host handlers are now cleaned properly on module unload (and also still on re/load to be safe). diff -r b94010de43f6 -r f79fda2d7e51 mod_host_guard/mod_host_guard.lua --- a/mod_host_guard/mod_host_guard.lua Mon Jun 25 22:32:54 2012 +0000 +++ b/mod_host_guard/mod_host_guard.lua Mon Jun 25 23:26:09 2012 +0000 @@ -63,7 +63,8 @@ end local function init_hosts() - for n,table in pairs(hosts) do + for n in pairs(hosts) do + -- This is a bit redundant but better safe then sorry. hosts[n].events.remove_handler("s2sin-established", s2s_hook) hosts[n].events.remove_handler("route/remote", rr_hook) hosts[n].events.remove_handler("stanza/jabber:server:dialback:result", s2s_hook) @@ -90,8 +91,18 @@ init_hosts() end +function module.unload() + module:log ("debug", "removing host handlers as module is being unloaded...") + for n in pairs(hosts) do + hosts[n].events.remove_handler("s2sin-established", s2s_hook) + hosts[n].events.remove_handler("route/remote", rr_hook) + hosts[n].events.remove_handler("stanza/jabber:server:dialback:result", s2s_hook) + end +end + if prosody.start_time then setup() else module:hook ("server-started", setup) end +