Comparison

core/hostmanager.lua @ 5361:38e7a5fafb28

hostmanager: Use rawget to check for activated hosts to prevent recursion in dynamic host loaders
author Matthew Wild <mwild1@gmail.com>
date Fri, 22 Mar 2013 11:24:54 +0000
parent 5360:e44cfbf0ae8d
child 5377:898454038524
comparison
equal deleted inserted replaced
5360:e44cfbf0ae8d 5361:38e7a5fafb28
23 require "core.s2smanager"; 23 require "core.s2smanager";
24 end 24 end
25 local incoming_s2s = _G.prosody.incoming_s2s; 25 local incoming_s2s = _G.prosody.incoming_s2s;
26 local core_route_stanza = _G.prosody.core_route_stanza; 26 local core_route_stanza = _G.prosody.core_route_stanza;
27 27
28 local pairs, select = pairs, select; 28 local pairs, select, rawget = pairs, select, rawget;
29 local tostring, type = tostring, type; 29 local tostring, type = tostring, type;
30 30
31 module "hostmanager" 31 module "hostmanager"
32 32
33 local hosts_loaded_once; 33 local hosts_loaded_once;
65 end 65 end
66 core_route_stanza(nil, stanza); 66 core_route_stanza(nil, stanza);
67 end 67 end
68 68
69 function activate(host, host_config) 69 function activate(host, host_config)
70 if hosts[host] then return nil, "The host "..host.." is already activated"; end 70 if rawget(hosts, host) then return nil, "The host "..host.." is already activated"; end
71 host_config = host_config or configmanager.getconfig()[host]; 71 host_config = host_config or configmanager.getconfig()[host];
72 if not host_config then return nil, "Couldn't find the host "..tostring(host).." defined in the current config"; end 72 if not host_config then return nil, "Couldn't find the host "..tostring(host).." defined in the current config"; end
73 local host_session = { 73 local host_session = {
74 host = host; 74 host = host;
75 s2sout = {}; 75 s2sout = {};