Software /
code /
prosody
Comparison
core/modulemanager.lua @ 9563:732314eb3258
modulemanager: Fix issues introduced in previous commit acf74ad0b795 [thanks luacheck, scansion]
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Fri, 26 Oct 2018 19:53:02 +0100 |
parent | 9562:acf74ad0b795 |
child | 9867:984f27e4b8a3 |
child | 10433:7777f25d5266 |
comparison
equal
deleted
inserted
replaced
9562:acf74ad0b795 | 9563:732314eb3258 |
---|---|
17 | 17 |
18 local prosody = prosody; | 18 local prosody = prosody; |
19 local hosts = prosody.hosts; | 19 local hosts = prosody.hosts; |
20 | 20 |
21 local xpcall = require "util.xpcall".xpcall; | 21 local xpcall = require "util.xpcall".xpcall; |
22 local debug_traceback = debug.traceback; | |
22 local setmetatable, rawget = setmetatable, rawget; | 23 local setmetatable, rawget = setmetatable, rawget; |
23 local ipairs, pairs, type, tostring, t_insert = ipairs, pairs, type, tostring, table.insert; | 24 local ipairs, pairs, type, t_insert = ipairs, pairs, type, table.insert; |
24 | |
25 local debug_traceback = debug.traceback; | |
26 local select = select; | |
27 local unpack = table.unpack or unpack; --luacheck: ignore 113 | |
28 | 25 |
29 local autoload_modules = {prosody.platform, "presence", "message", "iq", "offline", "c2s", "s2s", "s2s_auth_certs"}; | 26 local autoload_modules = {prosody.platform, "presence", "message", "iq", "offline", "c2s", "s2s", "s2s_auth_certs"}; |
30 local component_inheritable_modules = {"tls", "saslauth", "dialback", "iq", "s2s"}; | 27 local component_inheritable_modules = {"tls", "saslauth", "dialback", "iq", "s2s"}; |
31 | 28 |
32 -- We need this to let modules access the real global namespace | 29 -- We need this to let modules access the real global namespace |
176 end | 173 end |
177 | 174 |
178 api_instance.path = err; | 175 api_instance.path = err; |
179 | 176 |
180 modulemap[host][module_name] = pluginenv; | 177 modulemap[host][module_name] = pluginenv; |
181 local ok, err = xpcall(mod, debug.traceback); | 178 local ok, err = xpcall(mod, debug_traceback); |
182 if ok then | 179 if ok then |
183 -- Call module's "load" | 180 -- Call module's "load" |
184 if module_has_method(pluginenv, "load") then | 181 if module_has_method(pluginenv, "load") then |
185 ok, err = call_module_method(pluginenv, "load"); | 182 ok, err = call_module_method(pluginenv, "load"); |
186 if not ok then | 183 if not ok then |
318 end | 315 end |
319 | 316 |
320 function call_module_method(module, method, ...) | 317 function call_module_method(module, method, ...) |
321 local f = rawget(module.module, method); | 318 local f = rawget(module.module, method); |
322 if type(f) == "function" then | 319 if type(f) == "function" then |
323 return pcall(f, ...); | 320 return xpcall(f, debug_traceback, ...); |
324 else | 321 else |
325 return false, "no-such-method"; | 322 return false, "no-such-method"; |
326 end | 323 end |
327 end | 324 end |
328 | 325 |