net.dns: Be more strict about the records we cache
[prosody.git] / core / componentmanager.lua
index 6f5e28e608abc6dc35d104f8530fb4b59c910815..a16c01d2934a768008690b3364d6686d7b3cf7b8 100644 (file)
@@ -6,7 +6,7 @@
 -- COPYING file in the source package for more information.
 --
 
-local prosody = prosody;
+local prosody = _G.prosody;
 local log = require "util.logger".init("componentmanager");
 local configmanager = require "core.configmanager";
 local modulemanager = require "core.modulemanager";
@@ -26,7 +26,7 @@ local NULL = {};
 module "componentmanager"
 
 local function default_component_handler(origin, stanza)
-       log("warn", "Stanza being handled by default component, bouncing error");
+       log("warn", "Stanza being handled by default component; bouncing error for: %s", stanza:top_tag());
        if stanza.attr.type ~= "error" and stanza.attr.type ~= "result" then
                origin.send(st.error_reply(stanza, "wait", "service-unavailable", "Component unavailable"));
        end
@@ -51,7 +51,9 @@ function load_enabled_components(config)
        end
 end
 
-prosody.events.add_handler("server-starting", load_enabled_components);
+if prosody and prosody.events then
+       prosody.events.add_handler("server-starting", load_enabled_components);
+end
 
 function handle_stanza(origin, stanza)
        local node, host = jid_split(stanza.attr.to);
@@ -65,6 +67,7 @@ function handle_stanza(origin, stanza)
                component(origin, stanza, hosts[host]);
        else
                log("error", "Component manager recieved a stanza for a non-existing component: "..tostring(stanza));
+               default_component_handler(origin, stanza);
        end
 end
 
@@ -111,6 +114,7 @@ end
 
 function deregister_component(host)
        if components[host] then
+               modulemanager.unload(host, "tls");
                modulemanager.unload(host, "dialback");
                hosts[host].connected = nil;
                local host_config = configmanager.getconfig()[host];
@@ -119,7 +123,7 @@ function deregister_component(host)
                        components[host] = default_component_handler;
                else
                        -- Component not in config, or disabled, remove
-                       hosts[host] = nil;
+                       hosts[host] = nil; -- FIXME do proper unload of all modules and other cleanup before removing
                        components[host] = nil;
                end
                -- remove from disco_items