From 4f1fe31627e76881f0fb79d55d02e7ed2b612896 Mon Sep 17 00:00:00 2001 From: Badlop Date: Wed, 30 Jul 2008 18:11:14 +0000 Subject: [PATCH] * src/gen_mod.erl: When ejabberd is kindly stopped, don't forget modules configuration (EJAB-706) * src/ejabberd_app.erl: Likewise SVN Revision: 1497 --- ChangeLog | 4 ++++ src/ejabberd_app.erl | 2 +- src/gen_mod.erl | 20 ++++++++++++++++---- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index a1e4252ef..b3ba28949 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2008-07-30 Badlop + * src/gen_mod.erl: When ejabberd is kindly stopped, don't forget + modules configuration (EJAB-706) + * src/ejabberd_app.erl: Likewise + * src/msgs/uk.msg: Fix: each string in a single line * src/msgs/wa.msg: Likewise diff --git a/src/ejabberd_app.erl b/src/ejabberd_app.erl index 4c12069d1..38035710d 100644 --- a/src/ejabberd_app.erl +++ b/src/ejabberd_app.erl @@ -153,7 +153,7 @@ stop_modules() -> Modules -> lists:foreach( fun({Module, _Args}) -> - gen_mod:stop_module(Host, Module) + gen_mod:stop_module_keep_config(Host, Module) end, Modules) end end, ?MYHOSTS). diff --git a/src/gen_mod.erl b/src/gen_mod.erl index 29fbb1104..4333729ee 100644 --- a/src/gen_mod.erl +++ b/src/gen_mod.erl @@ -72,22 +72,34 @@ start_module(Host, Module, Opts) -> ok end. +%% @doc Stop the module in a host, and forget its configuration. stop_module(Host, Module) -> + case stop_module_keep_config(Host, Module) of + error -> + error; + ok -> + del_module_mnesia(Host, Module) + end. + +%% @doc Stop the module in a host, but keep its configuration. +%% As the module configuration is kept in the Mnesia local_config table, +%% when ejabberd is restarted the module will be started again. +%% This function is useful when ejabberd is being stopped +%% and it stops all modules. +stop_module_keep_config(Host, Module) -> case catch Module:stop(Host) of {'EXIT', Reason} -> - ?ERROR_MSG("~p", [Reason]); + ?ERROR_MSG("~p", [Reason]), + error; {wait, ProcList} when is_list(ProcList) -> lists:foreach(fun wait_for_process/1, ProcList), - del_module_mnesia(Host, Module), ets:delete(ejabberd_modules, {Module, Host}), ok; {wait, Process} -> wait_for_process(Process), - del_module_mnesia(Host, Module), ets:delete(ejabberd_modules, {Module, Host}), ok; _ -> - del_module_mnesia(Host, Module), ets:delete(ejabberd_modules, {Module, Host}), ok end.