]> granicus.if.org Git - ejabberd/commitdiff
Fail early when loading unavailable SIP or STUN modules
authorEvgeny Khramtsov <ekhramtsov@process-one.net>
Tue, 18 Sep 2018 15:19:42 +0000 (18:19 +0300)
committerEvgeny Khramtsov <ekhramtsov@process-one.net>
Tue, 18 Sep 2018 15:19:42 +0000 (18:19 +0300)
src/ejabberd_sip.erl
src/ejabberd_stun.erl

index 56cc5474a6dbea71a89a750a81da84fddc5a1073..f9061edbe7d0e4893e77bc4cc374a965a18f5b25 100644 (file)
 -ifndef(SIP).
 -include("logger.hrl").
 -export([accept/1, start/2, start_link/2, listen_options/0]).
-log_error() ->
-    ?CRITICAL_MSG("ejabberd is not compiled with SIP support", []).
+fail() ->
+    ?CRITICAL_MSG("Listening module ~s is not available: "
+                 "ejabberd is not compiled with SIP support",
+                 [?MODULE]),
+    erlang:error(sip_not_compiled).
 accept(_) ->
-    log_error(),
-    ok.
+    fail().
 listen_options() ->
-    log_error(),
-    [].
+    fail().
 start(_, _) ->
-    log_error(),
-    {error, sip_not_compiled}.
+    fail().
 start_link(_, _) ->
-    log_error(),
-    {error, sip_not_compiled}.
+    fail().
 -else.
 %% API
 -export([tcp_init/2, udp_init/2, udp_recv/5, start/2,
index 35057737b7c8172991e06166167e1e5843435a52..ef1d46f40efa60aad3cc31ea58848274cffbeb85 100644 (file)
 -ifndef(STUN).
 -include("logger.hrl").
 -export([accept/1, start/2, start_link/2, listen_options/0]).
-log_error() ->
-    ?CRITICAL_MSG("ejabberd is not compiled with STUN/TURN support", []).
+fail() ->
+    ?CRITICAL_MSG("Listening module ~s is not available: "
+                 "ejabberd is not compiled with STUN/TURN support",
+                 [?MODULE]),
+    erlang:error(stun_not_compiled).
 accept(_) ->
-    log_error(),
-    ok.
+    fail().
 listen_options() ->
-    log_error(),
-    [];
+    fail().
 start(_, _) ->
-    log_error(),
-    {error, sip_not_compiled}.
+    fail().
 start_link(_, _) ->
-    log_error(),
-    {error, sip_not_compiled}.
+    fail().
 -else.
 -export([tcp_init/2, udp_init/2, udp_recv/5, start/2,
         start_link/2, accept/1, listen_opt_type/1, listen_options/0]).