* src/gen_mod.erl: When ejabberd is kindly stopped, don't forget
authorBadlop <badlop@process-one.net>
Wed, 30 Jul 2008 18:11:14 +0000 (18:11 +0000)
committerBadlop <badlop@process-one.net>
Wed, 30 Jul 2008 18:11:14 +0000 (18:11 +0000)
modules configuration (EJAB-706)
* src/ejabberd_app.erl: Likewise

SVN Revision: 1497

ChangeLog
src/ejabberd_app.erl
src/gen_mod.erl

index 69a3e3e7e8c3830262f377a606c1cbb1d6bb43b2..d6946fc8a9cbbb49411e6530054febc5d0426bee 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-07-30  Badlop  <badlop@process-one.net>
+
+       * src/gen_mod.erl: When ejabberd is kindly stopped, don't forget
+       modules configuration (EJAB-706)
+       * src/ejabberd_app.erl: Likewise
+
 2008-07-28  Badlop  <badlop@process-one.net>
 
        * doc/guide.tex: Document how to get error message when ejabberd
index 8f335ad5b97b821cfc88d88bddf3bbd0cdc8c14c..f1e4413a104690edf7b0cb3b59d1e8f147399094 100644 (file)
@@ -152,7 +152,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).
index 29fbb1104ce10df793dd5c07d7f13ffb58fe8f4d..4333729eee8097e401d5e74e36da607bec810659 100644 (file)
@@ -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.