Software /
code /
prosody
Comparison
core/modulemanager.lua @ 674:4f506c627b49
modulemanager: module.unload now gets called when modules are being unloaded
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Wed, 07 Jan 2009 20:03:59 +0500 |
parent | 670:d5cf10b7fc44 |
child | 675:cc82394fea22 |
comparison
equal
deleted
inserted
replaced
673:c9bc58e84e96 | 674:4f506c627b49 |
---|---|
33 local setmetatable, setfenv, getfenv = setmetatable, setfenv, getfenv; | 33 local setmetatable, setfenv, getfenv = setmetatable, setfenv, getfenv; |
34 local pairs, ipairs = pairs, ipairs; | 34 local pairs, ipairs = pairs, ipairs; |
35 local t_insert = table.insert; | 35 local t_insert = table.insert; |
36 local type = type; | 36 local type = type; |
37 local next = next; | 37 local next = next; |
38 local rawget = rawget; | |
38 | 39 |
39 local tostring, print = tostring, print; | 40 local tostring, print = tostring, print; |
40 | 41 |
41 -- We need this to let modules access the real global namespace | 42 -- We need this to let modules access the real global namespace |
42 local _G = _G; | 43 local _G = _G; |
132 | 133 |
133 function unload(host, name, ...) | 134 function unload(host, name, ...) |
134 local mod = modulemap[host] and modulemap[host][name]; | 135 local mod = modulemap[host] and modulemap[host][name]; |
135 if not mod then return nil, "module-not-loaded"; end | 136 if not mod then return nil, "module-not-loaded"; end |
136 | 137 |
137 --[[if type(mod.unload) == "function" then | 138 if type(rawget(mod, "unload")) == "function" then |
138 local ok, err = pcall(mod.unload, ...) | 139 local ok, err = pcall(rawget(mod, "unload"), ...) |
139 if (not ok) and err then | 140 if (not ok) and err then |
140 log("warn", "Non-fatal error unloading module '%s' from '%s': %s", name, host, err); | 141 log("warn", "Non-fatal error unloading module '%s' from '%s': %s", name, host, err); |
141 end | 142 end |
142 end]] | 143 end |
143 modulemap[host][name] = nil; | 144 modulemap[host][name] = nil; |
144 features_table:remove(host, name); | 145 features_table:remove(host, name); |
145 local params = handler_table:get(host, name); -- , {module.host, origin_type, tag, xmlns} | 146 local params = handler_table:get(host, name); -- , {module.host, origin_type, tag, xmlns} |
146 for _, param in pairs(params) do | 147 for _, param in pairs(params) do |
147 local handlers = stanza_handlers:get(param[1], param[2], param[3], param[4]); | 148 local handlers = stanza_handlers:get(param[1], param[2], param[3], param[4]); |