mod_host_guard: host handlers are now cleaned properly on module unload (and also still on re/load to be safe).
--- 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
+