Comparison

core/componentmanager.lua @ 3587:d94aacb2771a

componentmanager, hostmanager, modulemanager, mod_component: Got rid of the useless hosts[*].connected property.
author Waqas Hussain <waqas20@gmail.com>
date Wed, 10 Nov 2010 03:39:38 +0500
parent 3586:78ed7ad330ab
child 3597:8090880f0e18
comparison
equal deleted inserted replaced
3586:78ed7ad330ab 3587:d94aacb2771a
38 local defined_hosts = config or configmanager.getconfig(); 38 local defined_hosts = config or configmanager.getconfig();
39 39
40 for host, host_config in pairs(defined_hosts) do 40 for host, host_config in pairs(defined_hosts) do
41 if host ~= "*" and ((host_config.core.enabled == nil or host_config.core.enabled) and type(host_config.core.component_module) == "string") then 41 if host ~= "*" and ((host_config.core.enabled == nil or host_config.core.enabled) and type(host_config.core.component_module) == "string") then
42 hosts[host] = create_component(host); 42 hosts[host] = create_component(host);
43 hosts[host].connected = false;
44 components[host] = default_component_handler; 43 components[host] = default_component_handler;
45 local ok, err = modulemanager.load(host, host_config.core.component_module); 44 local ok, err = modulemanager.load(host, host_config.core.component_module);
46 if not ok then 45 if not ok then
47 log("error", "Error loading %s component %s: %s", tostring(host_config.core.component_module), tostring(host), tostring(err)); 46 log("error", "Error loading %s component %s: %s", tostring(host_config.core.component_module), tostring(host), tostring(err));
48 else 47 else
57 prosody.events.add_handler("server-starting", load_enabled_components); 56 prosody.events.add_handler("server-starting", load_enabled_components);
58 end 57 end
59 58
60 function create_component(host, component, events) 59 function create_component(host, component, events)
61 -- TODO check for host well-formedness 60 -- TODO check for host well-formedness
62 return { type = "component", host = host, connected = true, s2sout = {}, 61 return { type = "component", host = host, s2sout = {},
63 events = events or events_new(), 62 events = events or events_new(),
64 dialback_secret = configmanager.get(host, "core", "dialback_secret") or uuid_gen(), 63 dialback_secret = configmanager.get(host, "core", "dialback_secret") or uuid_gen(),
65 disallow_s2s = configmanager.get(host, "core", "disallow_s2s"); }; 64 disallow_s2s = configmanager.get(host, "core", "disallow_s2s"); };
66 end 65 end
67 66
68 function register_component(host, component) 67 function register_component(host, component)
69 if not hosts[host] or (hosts[host].type == 'component' and not hosts[host].connected) then 68 if not hosts[host] or hosts[host].type == 'component' then
70 local old_events = hosts[host] and hosts[host].events; 69 local old_events = hosts[host] and hosts[host].events;
71 70
72 components[host] = component; 71 components[host] = component;
73 hosts[host] = create_component(host, component, old_events); 72 hosts[host] = create_component(host, component, old_events);
74 73
96 95
97 function deregister_component(host) 96 function deregister_component(host)
98 if components[host] then 97 if components[host] then
99 modulemanager.unload(host, "tls"); 98 modulemanager.unload(host, "tls");
100 modulemanager.unload(host, "dialback"); 99 modulemanager.unload(host, "dialback");
101 hosts[host].connected = nil;
102 local host_config = configmanager.getconfig()[host]; 100 local host_config = configmanager.getconfig()[host];
103 if host_config and ((host_config.core.enabled == nil or host_config.core.enabled) and type(host_config.core.component_module) == "string") then 101 if host_config and ((host_config.core.enabled == nil or host_config.core.enabled) and type(host_config.core.component_module) == "string") then
104 -- Set default handler 102 -- Set default handler
105 components[host] = default_component_handler; 103 components[host] = default_component_handler;
106 else 104 else