Merge with 0.4
[prosody.git] / core / componentmanager.lua
index 308dea57f030b65f19675c3a41ae4d020cf33005..d76b78495ad092010e034d75002b6fb50bd3e62d 100644 (file)
@@ -44,7 +44,7 @@ local function default_component_handler(origin, stanza)
        end
 end
 
-
+local components_loaded_once;
 function load_enabled_components(config)
        local defined_hosts = config or configmanager.getconfig();
                
@@ -56,7 +56,7 @@ function load_enabled_components(config)
                        if not ok then
                                log("error", "Error loading %s component %s: %s", tostring(host_config.core.component_module), tostring(host), tostring(err));
                        else
-                               log("info", "Activated %s component: %s", host_config.core.component_module, host);
+                               log("debug", "Activated %s component: %s", host_config.core.component_module, host);
                        end
                end
        end
@@ -80,8 +80,7 @@ end
 
 function create_component(host, component)
        -- TODO check for host well-formedness
-       local session = session or { type = "component", host = host, connected = true, s2sout = {} };
-       return session;
+       return { type = "component", host = host, connected = true, s2sout = {} };
 end
 
 function register_component(host, component, session)
@@ -104,6 +103,7 @@ end
 function deregister_component(host)
        if components[host] then
                modulemanager.unload(host, "dialback");
+               hosts[host].connected = nil;
                local host_config = configmanager.getconfig()[host];
                if host_config and ((host_config.core.enabled == nil or host_config.core.enabled) and type(host_config.core.component_module) == "string") then
                        -- Set default handler