aboutsummaryrefslogtreecommitdiffstats
path: root/core/modulemanager.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2012-03-14 21:37:00 +0000
committerMatthew Wild <mwild1@gmail.com>2012-03-14 21:37:00 +0000
commitce27bd5fe59bc640673abb52daa43110cfcd5c55 (patch)
tree26df7fb8e5a15abdd3105daf45cd3231259236b3 /core/modulemanager.lua
parent2c3103e84ae364bc20782575a8113c9b96c1cbd7 (diff)
downloadprosody-ce27bd5fe59bc640673abb52daa43110cfcd5c55.tar.gz
prosody-ce27bd5fe59bc640673abb52daa43110cfcd5c55.zip
modulemanager: Some refactoring. Deprecate module.host = "*", modules should call module:set_global() (which has been around since forever)
Diffstat (limited to 'core/modulemanager.lua')
-rw-r--r--core/modulemanager.lua20
1 files changed, 11 insertions, 9 deletions
diff --git a/core/modulemanager.lua b/core/modulemanager.lua
index 328224ae..f9f3a8b8 100644
--- a/core/modulemanager.lua
+++ b/core/modulemanager.lua
@@ -123,6 +123,7 @@ local function do_load_module(host, module_name)
if not modulemap[host] then
modulemap[host] = {};
+ hosts[host].modules = modulemap[host];
end
if modulemap[host][module_name] then
@@ -148,8 +149,6 @@ local function do_load_module(host, module_name)
api_instance.environment = pluginenv;
setfenv(mod, pluginenv);
- hosts[host].modules = modulemap[host];
- modulemap[host][module_name] = pluginenv;
local ok, err = pcall(mod);
if ok then
@@ -161,15 +160,18 @@ local function do_load_module(host, module_name)
end
end
- -- Use modified host, if the module set one
- if api_instance.host == "*" and host ~= "*" then
- modulemap[host][module_name] = nil;
- modulemap["*"][module_name] = pluginenv;
- api_instance:set_global();
+ modulemap[pluginenv.module.host][module_name] = pluginenv;
+ if pluginenv.module.host == "*" then
+ if not pluginenv.module.global then -- COMPAT w/pre-0.9
+ log("warn", "mod_%s: Setting module.host = '*' deprecated, call module:set_global() instead", module_name);
+ api_instance:set_global();
+ end
+ else
+ hosts[host].modules[module_name] = pluginenv;
end
- else
+ end
+ if not ok then
log("error", "Error initializing module '%s' on '%s': %s", module_name, host, err or "nil");
- do_unload_module(api_instance.host, module_name); -- Ignore error, module may be partially-loaded
end
return ok and pluginenv, err;
end