* src/ejabberd_listener.erl: Report error at startup if a listener

module isn't available or is not an ejabberd listener (EJAB-868)

SVN Revision: 1875
This commit is contained in:
Badlop 2009-02-13 23:52:24 +00:00
parent d0fc8fe056
commit 70e431787e
2 changed files with 26 additions and 2 deletions

View File

@ -1,3 +1,8 @@
2009-02-14 Badlop <badlop@process-one.net>
* src/ejabberd_listener.erl: Report error at startup if a listener
module isn't available or is not an ejabberd listener (EJAB-868)
2009-02-13 Badlop <badlop@process-one.net>
* src/mod_shared_roster.erl: Fix bug: a pending subscription

View File

@ -56,8 +56,13 @@ start_listeners() ->
Ls ->
Ls2 = lists:map(
fun({Port, Module, Opts}) ->
start_listener(Port, Module, Opts)
end, Ls),
case start_listener(Port, Module, Opts) of
{ok, _Pid} = R -> R;
{error, Error} ->
?ERROR_MSG(Error, []),
throw(Error)
end
end, Ls),
report_duplicated_portips(Ls),
{ok, {{one_for_one, 10, 1}, Ls2}}
end.
@ -225,6 +230,20 @@ accept(ListenSocket, Module, Opts) ->
%% @spec (Port, Module, Opts) -> {ok, Pid} | {error, Error}
start_listener(Port, Module, Opts) ->
case start_listener2(Port, Module, Opts) of
{ok, _Pid} = R -> R;
{error, {{'EXIT', {undef, _}}, _} = Error} ->
EStr = io_lib:format(
"Error starting the ejabberd listener: ~p.~n"
"It could not be loaded or is not an ejabberd listener.~n"
"Error: ~p~n", [Module, Error]),
{error, lists:flatten(EStr)};
{error, Error} ->
{error, Error}
end.
%% @spec (Port, Module, Opts) -> {ok, Pid} | {error, Error}
start_listener2(Port, Module, Opts) ->
%% It is only required to start the supervisor in some cases.
%% But it doesn't hurt to attempt to start it for any listener.
%% So, it's normal (and harmless) that in most cases this call returns: {error, {already_started, pid()}}