Software /
code /
prosody
Comparison
core/modulemanager.lua @ 1986:d4ba9d94eb74
modulemanager: Slightly rearranged code for more robust unloading of modules.
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Sat, 17 Oct 2009 23:48:30 +0500 |
parent | 1960:1e674dae31ae |
child | 1987:94ecd3e7be87 |
comparison
equal
deleted
inserted
replaced
1985:9b352c8a32e6 | 1986:d4ba9d94eb74 |
---|---|
168 local ok, err = call_module_method(mod, "unload"); | 168 local ok, err = call_module_method(mod, "unload"); |
169 if (not ok) and err then | 169 if (not ok) and err then |
170 log("warn", "Non-fatal error unloading module '%s' on '%s': %s", name, host, err); | 170 log("warn", "Non-fatal error unloading module '%s' on '%s': %s", name, host, err); |
171 end | 171 end |
172 end | 172 end |
173 modulemap[host][name] = nil; | |
174 local params = handler_table:get(host, name); -- , {module.host, origin_type, tag, xmlns} | 173 local params = handler_table:get(host, name); -- , {module.host, origin_type, tag, xmlns} |
175 for _, param in pairs(params or NULL) do | 174 for _, param in pairs(params or NULL) do |
176 local handlers = stanza_handlers:get(param[1], param[2], param[3], param[4]); | 175 local handlers = stanza_handlers:get(param[1], param[2], param[3], param[4]); |
177 if handlers then | 176 if handlers then |
178 handler_info[handlers[1]] = nil; | 177 handler_info[handlers[1]] = nil; |
185 for handler in pairs(handlers or NULL) do | 184 for handler in pairs(handlers or NULL) do |
186 (hosts[host] or prosody).events.remove_handler(event, handler); | 185 (hosts[host] or prosody).events.remove_handler(event, handler); |
187 end | 186 end |
188 end | 187 end |
189 hooks:remove(host, name); | 188 hooks:remove(host, name); |
189 modulemap[host][name] = nil; | |
190 return true; | 190 return true; |
191 end | 191 end |
192 | 192 |
193 function reload(host, name, ...) | 193 function reload(host, name, ...) |
194 local mod = get_module(host, name); | 194 local mod = get_module(host, name); |