diff options
author | Matthew Wild <mwild1@gmail.com> | 2012-11-22 21:01:00 +0000 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2012-11-22 21:01:00 +0000 |
commit | 032bbb82d3da940ae9df3f370a5e98c5b56b3d55 (patch) | |
tree | f70daf210feb67558ef27e20195d002fa3aef5d1 /core/modulemanager.lua | |
parent | 2cb192af38cad5e903bdd9a1f356a0ea01513de5 (diff) | |
parent | 565ea2bbe10267a1310c2efed6aaffecd59c6def (diff) | |
download | prosody-032bbb82d3da940ae9df3f370a5e98c5b56b3d55.tar.gz prosody-032bbb82d3da940ae9df3f370a5e98c5b56b3d55.zip |
Merge 0.9->trunk
Diffstat (limited to 'core/modulemanager.lua')
-rw-r--r-- | core/modulemanager.lua | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/core/modulemanager.lua b/core/modulemanager.lua index b0d54caa..4ba2c27e 100644 --- a/core/modulemanager.lua +++ b/core/modulemanager.lua @@ -111,7 +111,7 @@ local function do_unload_module(host, name) return true; end -local function do_load_module(host, module_name) +local function do_load_module(host, module_name, state) if not (host and module_name) then return nil, "insufficient-parameters"; elseif not hosts[host] and host ~= "*"then @@ -152,7 +152,8 @@ local function do_load_module(host, module_name) local _log = logger.init(host..":"..module_name); local api_instance = setmetatable({ name = module_name, host = host, - _log = _log, log = function (self, ...) return _log(...); end, event_handlers = new_multitable() } + _log = _log, log = function (self, ...) return _log(...); end, event_handlers = new_multitable(), + reloading = not not state, saved_state = state~=true and state or nil } , { __index = api }); local pluginenv = setmetatable({ module = api_instance }, { __index = _G }); @@ -176,6 +177,7 @@ local function do_load_module(host, module_name) log("warn", "Error loading module '%s' on '%s': %s", module_name, host, err or "nil"); end end + api_instance.reloading, api_instance.saved_state = nil, nil; if api_instance.host == "*" then if not api_instance.global then -- COMPAT w/pre-0.9 @@ -225,8 +227,9 @@ local function do_reload_module(host, name) end end + mod.module.reloading = true; do_unload_module(host, name); - local ok, err = do_load_module(host, name); + local ok, err = do_load_module(host, name, saved or true); if ok then mod = get_module(host, name); if module_has_method(mod, "restore") then |