]> granicus.if.org Git - ejabberd/commitdiff
* src/ejabberd_listener.erl: Report error at startup if a listener
authorBadlop <badlop@process-one.net>
Fri, 13 Feb 2009 23:52:24 +0000 (23:52 +0000)
committerBadlop <badlop@process-one.net>
Fri, 13 Feb 2009 23:52:24 +0000 (23:52 +0000)
module isn't available or is not an ejabberd listener (EJAB-868)

SVN Revision: 1875

ChangeLog
src/ejabberd_listener.erl

index f2dc68eb2246f3ba07745ea9a520ec97c121ad94..358cdd93766d88e6a8fd1c7de317d9d1f6f57956 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
index 03948120fab10c3e6fd2fd9fa449ca6e1f7492b2..5ca3bdeb09bf47b2cb857d3d3f657aa354caa00b 100644 (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()}}