diff options
| author | Christophe Romain <christophe.romain@process-one.net> | 2010-11-08 11:18:33 +0100 |
|---|---|---|
| committer | Christophe Romain <christophe.romain@process-one.net> | 2010-11-08 11:18:33 +0100 |
| commit | 5e0f2b8560ef3a63c0cc2a76c4c7749115926caf (patch) | |
| tree | 5c477d054aca88898fb09165632f39af8be4a884 | |
| parent | Re-raise exceptions caught in gen_mod:start_module/3 (EJAB-1335) (diff) | |
avoid node_call to break transaction (thanks to Karim Gemayel)(EJAB-1286)
| -rw-r--r-- | src/mod_pubsub/mod_pubsub.erl | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/mod_pubsub/mod_pubsub.erl b/src/mod_pubsub/mod_pubsub.erl index b02ffe3ce..0a51e5fad 100644 --- a/src/mod_pubsub/mod_pubsub.erl +++ b/src/mod_pubsub/mod_pubsub.erl @@ -308,12 +308,17 @@ init_plugins(Host, ServerHost, Opts) -> Plugins = gen_mod:get_opt(plugins, Opts, [?STDNODE]), PepMapping = gen_mod:get_opt(pep_mapping, Opts, []), ?DEBUG("** PEP Mapping : ~p~n",[PepMapping]), - lists:foreach(fun(Name) -> - ?DEBUG("** init ~s plugin",[Name]), - Plugin = list_to_atom(?PLUGIN_PREFIX ++ Name), - Plugin:init(Host, ServerHost, Opts) - end, Plugins), - {Plugins, TreePlugin, PepMapping}. + Plugins_OK = lists:foldl(fun(Name, Acc) -> + Plugin = list_to_atom(?PLUGIN_PREFIX ++ Name), + case catch apply(Plugin, init, [Host, ServerHost, Opts]) of + {'EXIT', _Error} -> + Acc; + _ -> + ?DEBUG("** init ~s plugin",[Name]), + [Name | Acc] + end + end, [], Plugins), + {Plugins_OK, TreePlugin, PepMapping}. -spec(terminate_plugins/4 :: @@ -4362,7 +4367,7 @@ tree_action(Host, Function, Args) -> node_call(Type, Function, Args) -> ?DEBUG("node_call ~p ~p ~p",[Type, Function, Args]), Module = list_to_atom(?PLUGIN_PREFIX++Type), - case catch apply(Module, Function, Args) of + case apply(Module, Function, Args) of {result, Result} -> {result, Result}; {error, Error} -> {error, Error}; {'EXIT', {undef, Undefined}} -> |
