Comparison

core/modulemanager.lua @ 4537:d8d257c13562

modulemanager: load(): Return and use the correct module object
author Matthew Wild <mwild1@gmail.com>
date Sun, 22 Jan 2012 19:27:06 +0000
parent 4535:d46e9ad4fe8a
child 4565:5a2212d3468e
comparison
equal deleted inserted replaced
4536:285450536ec0 4537:d8d257c13562
168 end 168 end
169 else 169 else
170 log("error", "Error initializing module '%s' on '%s': %s", module_name, host, err or "nil"); 170 log("error", "Error initializing module '%s' on '%s': %s", module_name, host, err or "nil");
171 do_unload_module(api_instance.host, module_name); -- Ignore error, module may be partially-loaded 171 do_unload_module(api_instance.host, module_name); -- Ignore error, module may be partially-loaded
172 end 172 end
173 return ok and mod, err; 173 return ok and pluginenv, err;
174 end 174 end
175 175
176 local function do_reload_module(host, name) 176 local function do_reload_module(host, name)
177 local mod = get_module(host, name); 177 local mod = get_module(host, name);
178 if not mod then return nil, "module-not-loaded"; end 178 if not mod then return nil, "module-not-loaded"; end
217 217
218 -- Load a module and fire module-loaded event 218 -- Load a module and fire module-loaded event
219 function load(host, name) 219 function load(host, name)
220 local mod, err = do_load_module(host, name); 220 local mod, err = do_load_module(host, name);
221 if mod then 221 if mod then
222 (hosts[mod.host] or prosody).events.fire_event("module-loaded", { module = module_name, host = host }); 222 (hosts[mod.module.host] or prosody).events.fire_event("module-loaded", { module = name, host = host });
223 end 223 end
224 return mod, err; 224 return mod, err;
225 end 225 end
226 226
227 -- Unload a module and fire module-unloaded 227 -- Unload a module and fire module-unloaded