]> granicus.if.org Git - ejabberd/commitdiff
Process unexpected messages uniformly
authorEvgeny Khramtsov <ekhramtsov@process-one.net>
Fri, 12 Jul 2019 08:55:36 +0000 (11:55 +0300)
committerEvgeny Khramtsov <ekhramtsov@process-one.net>
Fri, 12 Jul 2019 08:55:36 +0000 (11:55 +0300)
38 files changed:
src/ejabberd_access_permissions.erl
src/ejabberd_acme.erl
src/ejabberd_admin.erl
src/ejabberd_auth.erl
src/ejabberd_auth_ldap.erl
src/ejabberd_c2s.erl
src/ejabberd_captcha.erl
src/ejabberd_cluster.erl
src/ejabberd_commands.erl
src/ejabberd_ctl.erl
src/ejabberd_local.erl
src/ejabberd_mnesia.erl
src/ejabberd_oauth.erl
src/ejabberd_riak.erl
src/ejabberd_router_mnesia.erl
src/ejabberd_router_multicast.erl
src/ejabberd_router_redis.erl
src/ejabberd_sm.erl
src/ejabberd_sm_mnesia.erl
src/ejabberd_sm_redis.erl
src/ext_mod.erl
src/mod_announce.erl
src/mod_bosh_mnesia.erl
src/mod_bosh_redis.erl
src/mod_caps.erl
src/mod_fail2ban.erl
src/mod_http_fileserver.erl
src/mod_http_upload.erl
src/mod_mix.erl
src/mod_mqtt.erl
src/mod_muc_mnesia.erl
src/mod_ping.erl
src/mod_proxy65_mnesia.erl
src/mod_proxy65_service.erl
src/mod_shared_roster_ldap.erl
src/mod_sip_registrar.erl
src/mod_vcard_ldap.erl
src/translate.erl

index 2f63cb576d45b08d7b67c83c96b2e90256f473b6..673758fa495fb5824cc1bd3d1b3f125572783c69 100644 (file)
@@ -125,16 +125,19 @@ handle_call({can_access, Cmd, CallerInfo}, _From, State) ->
 handle_call(show_current_definitions, _From, State) ->
     {State2, Defs} = get_definitions(State),
     {reply, Defs, State2};
-handle_call(_Request, _From, State) ->
-    {reply, ok, State}.
+handle_call(Request, From, State) ->
+    ?WARNING_MSG("Unexpected call from ~p: ~p", [From, Request]),
+    {noreply, State}.
 
 -spec handle_cast(invalidate | term(), state()) -> {noreply, state()}.
 handle_cast(invalidate, State) ->
     {noreply, State#state{definitions = none}};
-handle_cast(_Request, State) ->
+handle_cast(Msg, State) ->
+    ?WARNING_MSG("Unexpected cast: ~p", [Msg]),
     {noreply, State}.
 
-handle_info(_Info, State) ->
+handle_info(Info, State) ->
+    ?WARNING_MSG("Unexpected info: ~p", [Info]),
     {noreply, State}.
 
 terminate(_Reason, _State) ->
index 8cb1b2625cd18cf96952118e3ecc3fcbe910fa3f..b080474d8c4332a4f210afff015dd2bf195bcbf7 100644 (file)
@@ -50,8 +50,9 @@ init([]) ->
            {stop, Why}
     end.
 
-handle_call(_Request, _From, State) ->
-    {stop, {unexpected_call, _Request, _From}, State}.
+handle_call(Request, From, State) ->
+    ?WARNING_MSG("Unexpected call from ~p: ~p", [From, Request]),
+    {noreply, State}.
 
 handle_cast(_Msg, State) ->
     ?WARNING_MSG("Unexpected cast: ~p", [_Msg]),
index bde2cde8f5dc5c8c3c5eee0f3d04bbb8ee746d59..1136f12b3d3fcd5d5ba737671ba2be2cdc02c9f3 100644 (file)
@@ -77,14 +77,16 @@ init([]) ->
     ejabberd_commands:register_commands(get_commands_spec()),
     {ok, #state{}}.
 
-handle_call(_Request, _From, State) ->
-    Reply = ok,
-    {reply, Reply, State}.
+handle_call(Request, From, State) ->
+    ?WARNING_MSG("Unexpected call from ~p: ~p", [From, Request]),
+    {noreply, State}.
 
-handle_cast(_Msg, State) ->
+handle_cast(Msg, State) ->
+    ?WARNING_MSG("Unexpected cast: ~p", [Msg]),
     {noreply, State}.
 
-handle_info(_Info, State) ->
+handle_info(Info, State) ->
+    ?WARNING_MSG("Unexpected info: ~p", [Info]),
     {noreply, State}.
 
 terminate(_Reason, _State) ->
index c5fda7d34d7964e5f4d8e1b80c8639356179f8a1..f97a40264fb0f467d87a25a444628999dec2595a 100644 (file)
@@ -117,9 +117,9 @@ init([]) ->
     init_cache(HostModules),
     {ok, #state{host_modules = HostModules}}.
 
-handle_call(_Request, _From, State) ->
-    Reply = ok,
-    {reply, Reply, State}.
+handle_call(Request, From, State) ->
+    ?WARNING_MSG("Unexpected call from ~p: ~p", [From, Request]),
+    {noreply, State}.
 
 handle_cast({host_up, Host}, #state{host_modules = HostModules} = State) ->
     Modules = auth_modules(Host),
@@ -150,7 +150,8 @@ handle_cast(Msg, State) ->
     ?WARNING_MSG("Unexpected cast: ~p", [Msg]),
     {noreply, State}.
 
-handle_info(_Info, State) ->
+handle_info(Info, State) ->
+    ?WARNING_MSG("Unexpected info: ~p", [Info]),
     {noreply, State}.
 
 terminate(_Reason, State) ->
index 3f542939527bb41014dac8939aeaa21c4fcfe3d4..4dfebddcd767d6c30764b6b4c9884e46e9c57970 100644 (file)
          dn_filter              :: binary() | undefined,
          dn_filter_attrs = []   :: [binary()]}).
 
-handle_cast(_Request, State) -> {noreply, State}.
+handle_cast(Msg, State) ->
+    ?WARNING_MSG("Unexpected cast: ~p", [Msg]),
+    {noreply, State}.
 
 code_change(_OldVsn, State, _Extra) -> {ok, State}.
 
-handle_info(_Info, State) -> {noreply, State}.
+handle_info(Info, State) ->
+    ?WARNING_MSG("Unexpected info: ~p", [Info]),
+    {noreply, State}.
 
 -define(LDAP_SEARCH_TIMEOUT, 5).
 
@@ -225,8 +229,9 @@ handle_call(get_state, _From, State) ->
     {reply, {ok, State}, State};
 handle_call(stop, _From, State) ->
     {stop, normal, ok, State};
-handle_call(_Request, _From, State) ->
-    {reply, bad_request, State}.
+handle_call(Request, From, State) ->
+    ?WARNING_MSG("Unexpected call from ~p: ~p", [From, Request]),
+    {noreply, State}.
 
 find_user_dn(User, State) ->
     ResAttrs = result_attrs(State),
index 94d0e22b7aabb58bfe11f0dec4b272b95101da3a..f0c609eb7cf2f1cae9b4c2032977edf2687897e4 100644 (file)
@@ -38,9 +38,9 @@
         handle_auth_success/4, handle_auth_failure/4, handle_send/3,
         handle_recv/3, handle_cdata/2, handle_unbinded_packet/2]).
 %% Hooks
--export([handle_unexpected_cast/2, process_auth_result/3,
-        reject_unauthenticated_packet/2, process_closed/2,
-        process_terminated/2, process_info/2]).
+-export([handle_unexpected_cast/2, handle_unexpected_call/3,
+        process_auth_result/3, reject_unauthenticated_packet/2,
+        process_closed/2, process_terminated/2, process_info/2]).
 %% API
 -export([get_presence/1, set_presence/2, resend_presence/1, resend_presence/2,
         open_session/1, call/3, cast/2, send/2, close/1, close/2, stop/1,
@@ -158,7 +158,9 @@ host_up(Host) ->
     ejabberd_hooks:add(c2s_auth_result, Host, ?MODULE,
                       process_auth_result, 100),
     ejabberd_hooks:add(c2s_handle_cast, Host, ?MODULE,
-                      handle_unexpected_cast, 100).
+                      handle_unexpected_cast, 100),
+    ejabberd_hooks:add(c2s_handle_call, Host, ?MODULE,
+                      handle_unexpected_call, 100).
 
 -spec host_down(binary()) -> ok.
 host_down(Host) ->
@@ -172,7 +174,9 @@ host_down(Host) ->
     ejabberd_hooks:delete(c2s_auth_result, Host, ?MODULE,
                          process_auth_result, 100),
     ejabberd_hooks:delete(c2s_handle_cast, Host, ?MODULE,
-                         handle_unexpected_cast, 100).
+                         handle_unexpected_cast, 100),
+    ejabberd_hooks:delete(c2s_handle_call, Host, ?MODULE,
+                         handle_unexpected_call, 100).
 
 %% Copies content of one c2s state to another.
 %% This is needed for session migration from one pid to another.
@@ -249,6 +253,10 @@ process_info(State, Info) ->
     ?WARNING_MSG("Unexpected info: ~p", [Info]),
     State.
 
+handle_unexpected_call(State, From, Msg) ->
+    ?WARNING_MSG("Unexpected call from ~p: ~p", [From, Msg]),
+    State.
+
 handle_unexpected_cast(State, Msg) ->
     ?WARNING_MSG("Unexpected cast: ~p", [Msg]),
     State.
index 02cf2659a998d396a569d6495cefb5d43e530b1e..720f375c59334e56910764034f3a2f52e15d712c 100644 (file)
@@ -341,10 +341,13 @@ handle_call(config_reloaded, _From, #state{enabled = Enabled} = State) ->
                     State
             end,
     {reply, ok, State1};
-handle_call(_Request, _From, State) ->
-    {reply, bad_request, State}.
+handle_call(Request, From, State) ->
+    ?WARNING_MSG("Unexpected call from ~p: ~p", [From, Request]),
+    {noreply, State}.
 
-handle_cast(_Msg, State) -> {noreply, State}.
+handle_cast(Msg, State) ->
+    ?WARNING_MSG("Unexpected cast: ~p", [Msg]),
+    {noreply, State}.
 
 handle_info({remove_id, Id}, State) ->
     ?DEBUG("CAPTCHA ~p timed out", [Id]),
@@ -355,7 +358,9 @@ handle_info({remove_id, Id}, State) ->
        _ -> ok
     end,
     {noreply, State};
-handle_info(_Info, State) -> {noreply, State}.
+handle_info(Info, State) ->
+    ?WARNING_MSG("Unexpected info: ~p", [Info]),
+    {noreply, State}.
 
 terminate(_Reason, #state{enabled = Enabled}) ->
     if Enabled -> unregister_handlers();
index e2b02f7f804ac7fb17603549e5a64ba33beccb0d..888420f34c200498ff06e02d0b4b81767c361f33 100644 (file)
@@ -167,11 +167,12 @@ init([]) ->
            {stop, Reason}
     end.
 
-handle_call(_Request, _From, State) ->
-    Reply = ok,
-    {reply, Reply, State}.
+handle_call(Request, From, State) ->
+    ?WARNING_MSG("Unexpected call from ~p: ~p", [From, Request]),
+    {noreply, State}.
 
-handle_cast(_Msg, State) ->
+handle_cast(Msg, State) ->
+    ?WARNING_MSG("Unexpected cast: ~p", [Msg]),
     {noreply, State}.
 
 handle_info({node_up, Node}, State) ->
@@ -180,7 +181,8 @@ handle_info({node_up, Node}, State) ->
 handle_info({node_down, Node}, State) ->
     ?INFO_MSG("Node ~s has left", [Node]),
     {noreply, State};
-handle_info(_Info, State) ->
+handle_info(Info, State) ->
+    ?WARNING_MSG("Unexpected info: ~p", [Info]),
     {noreply, State}.
 
 terminate(_Reason, _State) ->
index 4c6b3b6958b66160b23f3b4bdbc55b261b2e580c..b3c3ef4d525eef5918d93663f0076de2d65e0bfa 100644 (file)
@@ -292,14 +292,16 @@ init([]) ->
     register_commands(get_commands_spec()),
     {ok, #state{}}.
 
-handle_call(_Request, _From, State) ->
-    Reply = ok,
-    {reply, Reply, State}.
+handle_call(Request, From, State) ->
+    ?WARNING_MSG("Unexpected call from ~p: ~p", [From, Request]),
+    {noreply, State}.
 
-handle_cast(_Msg, State) ->
+handle_cast(Msg, State) ->
+    ?WARNING_MSG("Unexpected cast: ~p", [Msg]),
     {noreply, State}.
 
-handle_info(_Info, State) ->
+handle_info(Info, State) ->
+    ?WARNING_MSG("Unexpected info: ~p", [Info]),
     {noreply, State}.
 
 terminate(_Reason, _State) ->
index c9dfff9c600dd79a01fcd7842da847d81cc8fef0..45169cdcfb4d98bee7809d18b8689df199ae5ab6 100644 (file)
@@ -114,14 +114,16 @@ init([]) ->
     ets:new(ejabberd_ctl_host_cmds, [named_table, set, public]),
     {ok, #state{}}.
 
-handle_call(_Request, _From, State) ->
-    Reply = ok,
-    {reply, Reply, State}.
+handle_call(Request, From, State) ->
+    ?WARNING_MSG("Unexpected call from ~p: ~p", [From, Request]),
+    {noreply, State}.
 
-handle_cast(_Msg, State) ->
+handle_cast(Msg, State) ->
+    ?WARNING_MSG("Unexpected cast: ~p", [Msg]),
     {noreply, State}.
 
-handle_info(_Info, State) ->
+handle_info(Info, State) ->
+    ?WARNING_MSG("Unexpected info: ~p", [Info]),
     {noreply, State}.
 
 terminate(_Reason, _State) ->
index 91a9264a56b1500ebbbdacf76cedc88c7d47455d..6e68ef3128477bf45eed958b359c9eb7360f07e3 100644 (file)
@@ -122,10 +122,13 @@ init([]) ->
     update_table(),
     {ok, #state{}}.
 
-handle_call(_Request, _From, State) ->
-    Reply = ok, {reply, Reply, State}.
+handle_call(Request, From, State) ->
+    ?WARNING_MSG("Unexpected call from ~p: ~p", [From, Request]),
+    {noreply, State}.
 
-handle_cast(_Msg, State) -> {noreply, State}.
+handle_cast(Msg, State) ->
+    ?WARNING_MSG("Unexpected cast: ~p", [Msg]),
+    {noreply, State}.
 
 handle_info({route, Packet}, State) ->
     route(Packet),
index 3df981124cdc6652eaecf2fbb7d46e8823ff913c..3cf2e460acbeb6101c9ef009dd9d2d506cbf6886 100644 (file)
@@ -97,13 +97,16 @@ handle_call({create, Module, Name, TabDef}, _From, State) ->
            Tables = maps:put(Name, {TabDef, Result}, State#state.tables),
            {reply, Result, State#state{tables = Tables}}
     end;
-handle_call(_Request, _From, State) ->
+handle_call(Request, From, State) ->
+    ?WARNING_MSG("Unexpected call from ~p: ~p", [From, Request]),
     {noreply, State}.
 
-handle_cast(_Msg, State) ->
+handle_cast(Msg, State) ->
+    ?WARNING_MSG("Unexpected cast: ~p", [Msg]),
     {noreply, State}.
 
-handle_info(_Info, State) ->
+handle_info(Info, State) ->
+    ?WARNING_MSG("Unexpected info: ~p", [Info]),
     {noreply, State}.
 
 terminate(_Reason, _State) ->
index 55a414f15057e7aca863af8e9e2787a79b54c30c..28f9b0de0e1420eb8f6f4a9c9a3cd1d650ea6cea 100644 (file)
@@ -154,10 +154,13 @@ init([]) ->
     erlang:send_after(expire() * 1000, self(), clean),
     {ok, ok}.
 
-handle_call(_Request, _From, State) ->
-    {reply, bad_request, State}.
+handle_call(Request, From, State) ->
+    ?WARNING_MSG("Unexpected call from ~p: ~p", [From, Request]),
+    {noreply, State}.
 
-handle_cast(_Msg, State) -> {noreply, State}.
+handle_cast(Msg, State) ->
+    ?WARNING_MSG("Unexpected cast: ~p", [Msg]),
+    {noreply, State}.
 
 handle_info(clean, State) ->
     {MegaSecs, Secs, MiniSecs} = os:timestamp(),
@@ -167,7 +170,9 @@ handle_info(clean, State) ->
     erlang:send_after(trunc(expire() * 1000 * (1 + MiniSecs / 1000000)),
                       self(), clean),
     {noreply, State};
-handle_info(_Info, State) -> {noreply, State}.
+handle_info(Info, State) ->
+    ?WARNING_MSG("Unexpected info: ~p", [Info]),
+    {noreply, State}.
 
 terminate(_Reason, _State) -> ok.
 
index 5bf783612a942c964f98748550d4804e0b6b795c..05015a204b730edbec4fb2425b31c6933ffc10e2 100644 (file)
@@ -447,19 +447,20 @@ init([Server, Port, Options]) ->
 %% @private
 handle_call(get_pid, _From, #state{pid = Pid} = State) ->
     {reply, {ok, Pid}, State};
-handle_call(_Request, _From, State) ->
-    Reply = ok,
-    {reply, Reply, State}.
+handle_call(Request, From, State) ->
+    ?WARNING_MSG("Unexpected call from ~p: ~p", [From, Request]),
+    {noreply, State}.
 
 %% @private
-handle_cast(_Msg, State) ->
+handle_cast(Msg, State) ->
+    ?WARNING_MSG("Unexpected cast: ~p", [Msg]),
     {noreply, State}.
 
 %% @private
 handle_info({'DOWN', _MonitorRef, _Type, _Object, _Info}, State) ->
     {stop, normal, State};
-handle_info(_Info, State) ->
-    ?ERROR_MSG("Unexpected info: ~p", [_Info]),
+handle_info(Info, State) ->
+    ?ERROR_MSG("Unexpected info: ~p", [Info]),
     {noreply, State}.
 
 %% @private
index cfca2f9809d4d23d39d36c79182b1fcd2e4f93bf..98d03cdd9af23d762030d3378eaf7ecf8becad78 100644 (file)
@@ -161,11 +161,12 @@ init([]) ->
          fun(#route{pid = Pid}) -> Pid end))),
     {ok, #state{}}.
 
-handle_call(_Request, _From, State) ->
-    Reply = ok,
-    {reply, Reply, State}.
+handle_call(Request, From, State) ->
+    ?WARNING_MSG("Unexpected call from ~p: ~p", [From, Request]),
+    {noreply, State}.
 
-handle_cast(_Msg, State) ->
+handle_cast(Msg, State) ->
+    ?WARNING_MSG("Unexpected cast: ~p", [Msg]),
     {noreply, State}.
 
 handle_info({mnesia_table_event,
index 463444add3e2c0d797a41516d98712e213641ad6..59df9ec9d8ef87c4ab4905545f36ea5235344ccc 100644 (file)
@@ -136,9 +136,9 @@ init([]) ->
 %%                                      {stop, Reason, State}
 %% Description: Handling call messages
 %%--------------------------------------------------------------------
-handle_call(_Request, _From, State) ->
-    Reply = ok,
-    {reply, Reply, State}.
+handle_call(Request, From, State) ->
+    ?WARNING_MSG("Unexpected call from ~p: ~p", [From, Request]),
+    {noreply, State}.
 
 %%--------------------------------------------------------------------
 %% Function: handle_cast(Msg, State) -> {noreply, State} |
@@ -146,7 +146,8 @@ handle_call(_Request, _From, State) ->
 %%                                      {stop, Reason, State}
 %% Description: Handling cast messages
 %%--------------------------------------------------------------------
-handle_cast(_Msg, State) ->
+handle_cast(Msg, State) ->
+    ?WARNING_MSG("Unexpected cast: ~p", [Msg]),
     {noreply, State}.
 
 %%--------------------------------------------------------------------
@@ -182,7 +183,8 @@ handle_info({'DOWN', _Ref, _Type, Pid, _Info}, State) ->
        end,
     mnesia:transaction(F),
     {noreply, State};
-handle_info(_Info, State) ->
+handle_info(Info, State) ->
+    ?WARNING_MSG("Unexpected info: ~p", [Info]),
     {noreply, State}.
 
 %%--------------------------------------------------------------------
index 3213901a611aeb42d6535d19a55e064d4845a0b7..b0f79d2a30a352ea136a0fce0b8dd4120660a6d3 100644 (file)
@@ -131,11 +131,12 @@ init([]) ->
     clean_table(),
     {ok, #state{}}.
 
-handle_call(_Request, _From, State) ->
-    Reply = ok,
-    {reply, Reply, State}.
+handle_call(Request, From, State) ->
+    ?WARNING_MSG("Unexpected call from ~p: ~p", [From, Request]),
+    {noreply, State}.
 
-handle_cast(_Msg, State) ->
+handle_cast(Msg, State) ->
+    ?WARNING_MSG("Unexpected cast: ~p", [Msg]),
     {noreply, State}.
 
 handle_info(Info, State) ->
index 13ffa1af0e503e773cc9a4f566f937a93038c5e3..7d34e66bb7a9be74b1ad250231eed12a93e81016 100644 (file)
@@ -491,10 +491,13 @@ init([]) ->
            {stop, Why}
     end.
 
-handle_call(_Request, _From, State) ->
-    Reply = ok, {reply, Reply, State}.
+handle_call(Request, From, State) ->
+    ?WARNING_MSG("Unexpected call from ~p: ~p", [From, Request]),
+    {noreply, State}.
 
-handle_cast(_Msg, State) -> {noreply, State}.
+handle_cast(Msg, State) ->
+    ?WARNING_MSG("Unexpected cast: ~p", [Msg]),
+    {noreply, State}.
 
 handle_info({route, Packet}, State) ->
     try route(Packet)
index 5e36a3d8a0b21dc847acff79bb7fd61eb08d863c..9626ba3d6b8b65d9620479db2f43ea609b15ad2b 100644 (file)
@@ -41,6 +41,7 @@
         terminate/2, code_change/3, start_link/0]).
 
 -include("ejabberd_sm.hrl").
+-include("logger.hrl").
 -include_lib("stdlib/include/ms_transform.hrl").
 
 -record(state, {}).
@@ -102,11 +103,12 @@ init([]) ->
     mnesia:subscribe(system),
     {ok, #state{}}.
 
-handle_call(_Request, _From, State) ->
-    Reply = ok,
-    {reply, Reply, State}.
+handle_call(Request, From, State) ->
+    ?WARNING_MSG("Unexpected call from ~p: ~p", [From, Request]),
+    {noreply, State}.
 
-handle_cast(_Msg, State) ->
+handle_cast(Msg, State) ->
+    ?WARNING_MSG("Unexpected cast: ~p", [Msg]),
     {noreply, State}.
 
 handle_info({mnesia_system_event, {mnesia_down, Node}}, State) ->
@@ -123,7 +125,8 @@ handle_info({mnesia_system_event, {mnesia_down, Node}}, State) ->
               mnesia:dirty_delete_object(S)
       end, Sessions),
     {noreply, State};
-handle_info(_Info, State) ->
+handle_info(Info, State) ->
+    ?WARNING_MSG("Unexpected info: ~p", [Info]),
     {noreply, State}.
 
 terminate(_Reason, _State) ->
index 67e7701c6ef17ef200aad8f91d055128209ded95..c552f7285c4bc88228e0f39ef5181f4a7aa24498 100644 (file)
@@ -148,11 +148,12 @@ init([]) ->
        {error, Why} -> {stop, Why}
     end.
 
-handle_call(_Request, _From, State) ->
-    Reply = ok,
-    {reply, Reply, State}.
+handle_call(Request, From, State) ->
+    ?WARNING_MSG("Unexpected call from ~p: ~p", [From, Request]),
+    {noreply, State}.
 
-handle_cast(_Msg, State) ->
+handle_cast(Msg, State) ->
+    ?WARNING_MSG("Unexpected cast: ~p", [Msg]),
     {noreply, State}.
 
 handle_info({redis_message, ?SM_KEY, Data}, State) ->
@@ -220,7 +221,7 @@ clean_table(Node) ->
     end.
 
 clean_node_sessions(Node, Host) ->
-    case load_script() of 
+    case load_script() of
         {ok, SHA} ->
             clean_node_sessions(Node, Host, SHA);
         Err ->
index 607f7b080c783756b545d209c69b5e19d2849595..75338b991e8a72be7e47d09e5c46ba37da8f86da 100644 (file)
@@ -63,14 +63,16 @@ add_paths() ->
     [code:add_patha(module_ebin_dir(Module))
      || {Module, _} <- installed()].
 
-handle_call(_Request, _From, State) ->
-    Reply = ok,
-    {reply, Reply, State}.
+handle_call(Request, From, State) ->
+    ?WARNING_MSG("Unexpected call from ~p: ~p", [From, Request]),
+    {noreply, State}.
 
-handle_cast(_Msg, State) ->
+handle_cast(Msg, State) ->
+    ?WARNING_MSG("Unexpected cast: ~p", [Msg]),
     {noreply, State}.
 
-handle_info(_Info, State) ->
+handle_info(Info, State) ->
+    ?WARNING_MSG("Unexpected info: ~p", [Info]),
     {noreply, State}.
 
 terminate(_Reason, _State) ->
index bdd2751b78763b0f17dc897c58d2b61d0bbfc0d2..dab1eb6f6875bd50879c279855c4d804ddf26c8d 100644 (file)
@@ -117,7 +117,8 @@ init([Host, Opts]) ->
                       ?MODULE, send_motd, 50),
     {ok, #state{host = Host}}.
 
-handle_call(_Call, _From, State) ->
+handle_call(Request, From, State) ->
+    ?WARNING_MSG("Unexpected call from ~p: ~p", [From, Request]),
     {noreply, State}.
 
 handle_cast({F, #message{from = From, to = To} = Pkt}, State) when is_atom(F) ->
index 824e06b551427dc6027b9d7c879b2bcf9352bef6..fd3135c31a3f9e7175f2f49caa37a7bc3f4454cf 100644 (file)
@@ -102,11 +102,12 @@ handle_call({write, Session}, _From, State) ->
 handle_call({delete, Session}, _From, State) ->
     Res = delete_session(Session),
     {reply, Res, State};
-handle_call(_Request, _From, State) ->
-    Reply = ok,
-    {reply, Reply, State}.
+handle_call(Request, From, State) ->
+    ?WARNING_MSG("Unexpected call from ~p: ~p", [From, Request]),
+    {noreply, State}.
 
-handle_cast(_Msg, State) ->
+handle_cast(Msg, State) ->
+    ?WARNING_MSG("Unexpected cast: ~p", [Msg]),
     {noreply, State}.
 
 handle_info({write, Session}, State) ->
@@ -115,8 +116,8 @@ handle_info({write, Session}, State) ->
 handle_info({delete, Session}, State) ->
     delete_session(Session),
     {noreply, State};
-handle_info(_Info, State) ->
-    ?ERROR_MSG("Unexpected info: ~p", [_Info]),
+handle_info(Info, State) ->
+    ?WARNING_MSG("Unexpected info: ~p", [Info]),
     {noreply, State}.
 
 terminate(_Reason, _State) ->
index c1840604ea2a2081fc846e8587b2aee88fb90785..a55fbdf09e90bafcebda69704b3c8aba36898525 100644 (file)
@@ -1,7 +1,7 @@
 %%%----------------------------------------------------------------------
 %%% File    : mod_bosh_redis.erl
 %%% Author  : Evgeny Khramtsov <ekhramtsov@process-one.net>
-%%% Purpose : 
+%%% Purpose :
 %%% Created : 28 Mar 2017 by Evgeny Khramtsov <ekhramtsov@process-one.net>
 %%%
 %%%
@@ -107,18 +107,19 @@ init([]) ->
     clean_table(),
     {ok, #state{}}.
 
-handle_call(_Request, _From, State) ->
-    Reply = ok,
-    {reply, Reply, State}.
+handle_call(Request, From, State) ->
+    ?WARNING_MSG("Unexpected call from ~p: ~p", [From, Request]),
+    {noreply, State}.
 
-handle_cast(_Msg, State) ->
+handle_cast(Msg, State) ->
+    ?WARNING_MSG("Unexpected cast: ~p", [Msg]),
     {noreply, State}.
 
 handle_info({redis_message, ?BOSH_KEY, SID}, State) ->
     ets_cache:delete(?BOSH_CACHE, SID),
     {noreply, State};
 handle_info(Info, State) ->
-    ?ERROR_MSG("Unexpected info: ~p", [Info]),
+    ?WARNING_MSG("Unexpected info: ~p", [Info]),
     {noreply, State}.
 
 terminate(_Reason, _State) ->
index ca12691945e1c4608b3f2134b7f9e4c5b972677e..05f28a5a282ae39e7f396a708fdd005a6e15fdaa 100644 (file)
@@ -288,10 +288,13 @@ init([Host, Opts]) ->
 
 handle_call(stop, _From, State) ->
     {stop, normal, ok, State};
-handle_call(_Req, _From, State) ->
-    {reply, {error, badarg}, State}.
+handle_call(Request, From, State) ->
+    ?WARNING_MSG("Unexpected call from ~p: ~p", [From, Request]),
+    {noreply, State}.
 
-handle_cast(_Msg, State) -> {noreply, State}.
+handle_cast(Msg, State) ->
+    ?WARNING_MSG("Unexpected cast: ~p", [Msg]),
+    {noreply, State}.
 
 handle_info({iq_reply, IQReply, {Host, From, To, Caps, SubNodes}}, State) ->
     feature_response(IQReply, Host, From, To, Caps, SubNodes),
index 770393914485eb088cb9f955b8cab25c699a9ecf..1647f69bbc644ac9545868f804e3ba0f7f3e7b0c 100644 (file)
@@ -135,12 +135,12 @@ init([Host, _Opts]) ->
     erlang:send_after(?CLEAN_INTERVAL, self(), clean),
     {ok, #state{host = Host}}.
 
-handle_call(_Request, _From, State) ->
-    Reply = ok,
-    {reply, Reply, State}.
+handle_call(Request, From, State) ->
+    ?WARNING_MSG("Unexpected call from ~p: ~p", [From, Request]),
+    {noreply, State}.
 
 handle_cast(_Msg, State) ->
-    ?ERROR_MSG("Unexpected cast = ~p", [_Msg]),
+    ?WARNING_MSG("Unexpected cast = ~p", [_Msg]),
     {noreply, State}.
 
 handle_info(clean, State) ->
@@ -152,7 +152,7 @@ handle_info(clean, State) ->
     erlang:send_after(?CLEAN_INTERVAL, self(), clean),
     {noreply, State};
 handle_info(_Info, State) ->
-    ?ERROR_MSG("Unexpected info = ~p", [_Info]),
+    ?WARNING_MSG("Unexpected info = ~p", [_Info]),
     {noreply, State}.
 
 terminate(_Reason, #state{host = Host}) ->
index 71cc6b1788046744c45f8f3335f1e7ddeee118a9..ea52eda6b30a6174e234129115b4d490d5e0964d 100644 (file)
@@ -198,8 +198,9 @@ handle_call({serve, LocalPath, Auth, RHeaders}, _From, State) ->
                  State#state.default_content_type, State#state.content_types,
                  State#state.user_access, IfModifiedSince),
     {reply, Reply, State};
-handle_call(_Request, _From, State) ->
-    {reply, ok, State}.
+handle_call(Request, From, State) ->
+    ?WARNING_MSG("Unexpected call from ~p: ~p", [From, Request]),
+    {noreply, State}.
 
 %%--------------------------------------------------------------------
 %% Function: handle_cast(Msg, State) -> {noreply, State} |
@@ -231,7 +232,8 @@ handle_cast(Msg, State) ->
 %%                                       {stop, Reason, State}
 %% Description: Handling all non call/cast messages
 %%--------------------------------------------------------------------
-handle_info(_Info, State) ->
+handle_info(Info, State) ->
+    ?WARNING_MSG("Unexpected info: ~p", [Info]),
     {noreply, State}.
 
 %%--------------------------------------------------------------------
index 9cd828ebfd97d8d891974e692342d1e13d7f925f..a3414b3b1df1338aa8377b833bfabd192601883d 100644 (file)
@@ -301,12 +301,12 @@ handle_call(get_conf, _From,
                   custom_headers = CustomHeaders} = State) ->
     {reply, {ok, DocRoot, CustomHeaders}, State};
 handle_call(Request, From, State) ->
-    ?ERROR_MSG("Unexpected request from ~p: ~p", [From, Request]),
+    ?WARNING_MSG("Unexpected call from ~p: ~p", [From, Request]),
     {noreply, State}.
 
 -spec handle_cast(_, state()) -> {noreply, state()}.
 handle_cast(Request, State) ->
-    ?ERROR_MSG("Unexpected request: ~p", [Request]),
+    ?WARNING_MSG("Unexpected cast: ~p", [Request]),
     {noreply, State}.
 
 -spec handle_info(timeout | _, state()) -> {noreply, state()}.
@@ -337,7 +337,7 @@ handle_info({timeout, _TRef, Slot}, State) ->
     NewState = del_slot(Slot, State),
     {noreply, NewState};
 handle_info(Info, State) ->
-    ?ERROR_MSG("Unexpected info: ~p", [Info]),
+    ?WARNING_MSG("Unexpected info: ~p", [Info]),
     {noreply, State}.
 
 -spec terminate(normal | shutdown | {shutdown, _} | _, state()) -> ok.
index 6b768b70275e86fbf8f950afbb1a1180fda21a81..a3f80d5ad140cf4c448e78210c26cc2a0dd9cede 100644 (file)
@@ -268,8 +268,8 @@ init([Host, Opts]) ->
            {stop, db_failure}
     end.
 
-handle_call(Request, _From, State) ->
-    ?WARNING_MSG("Unexpected call: ~p", [Request]),
+handle_call(Request, From, State) ->
+    ?WARNING_MSG("Unexpected call from ~p: ~p", [From, Request]),
     {noreply, State}.
 
 handle_cast(Request, State) ->
index 1649ef50d55f97da64028077019918554a88c8a1..c76d910a4a4f098370a276d25f3d492cf853feda 100644 (file)
@@ -176,14 +176,16 @@ init([Host, Opts]) ->
            {stop, Why}
     end.
 
-handle_call(_Request, _From, State) ->
-    Reply = ok,
-    {reply, Reply, State}.
+handle_call(Request, From, State) ->
+    ?WARNING_MSG("Unexpected call from ~p: ~p", [From, Request]),
+    {noreply, State}.
 
-handle_cast(_Msg, State) ->
+handle_cast(Msg, State) ->
+    ?WARNING_MSG("Unexpected cast: ~p", [Msg]),
     {noreply, State}.
 
-handle_info(_Info, State) ->
+handle_info(Info, State) ->
+    ?WARNING_MSG("Unexpected info: ~p", [Info]),
     {noreply, State}.
 
 terminate(_Reason, _State) ->
index 0b1321f62011322771c1bf53f6eca04b7722e04b..e5b98fb78f3d6eeed25bb27c583006c74fedd608 100644 (file)
@@ -329,11 +329,12 @@ init([_Host, Opts]) ->
     end,
     {ok, #state{}}.
 
-handle_call(_Request, _From, State) ->
-    Reply = ok,
-    {reply, Reply, State}.
+handle_call(Request, From, State) ->
+    ?WARNING_MSG("Unexpected call from ~p: ~p", [From, Request]),
+    {noreply, State}.
 
-handle_cast(_Msg, State) ->
+handle_cast(Msg, State) ->
+    ?WARNING_MSG("Unexpected cast: ~p", [Msg]),
     {noreply, State}.
 
 handle_info({mnesia_system_event, {mnesia_down, Node}}, State) ->
@@ -342,7 +343,7 @@ handle_info({mnesia_system_event, {mnesia_down, Node}}, State) ->
 handle_info({mnesia_system_event, {mnesia_up, _Node}}, State) ->
     {noreply, State};
 handle_info(Info, State) ->
-    ?ERROR_MSG("Unexpected info: ~p", [Info]),
+    ?WARNING_MSG("Unexpected info: ~p", [Info]),
     {noreply, State}.
 
 terminate(_Reason, _State) ->
index e0e2aec6da64406699957c9c8ea051eabc71f51b..1d926708b94b1a810e152df90133fca41bcd425c 100644 (file)
@@ -107,8 +107,9 @@ terminate(_Reason, #state{host = Host}) ->
 
 handle_call(stop, _From, State) ->
     {stop, normal, ok, State};
-handle_call(_Req, _From, State) ->
-    {reply, {error, badarg}, State}.
+handle_call(Request, From, State) ->
+    ?WARNING_MSG("Unexpected call from ~p: ~p", [From, Request]),
+    {noreply, State}.
 
 handle_cast({reload, Host, NewOpts, _OldOpts},
            #state{timers = Timers} = OldState) ->
@@ -162,7 +163,9 @@ handle_info({timeout, _TRef, {ping, JID}}, State) ->
     Timers = add_timer(JID, State#state.ping_interval,
                       State#state.timers),
     {noreply, State#state{timers = Timers}};
-handle_info(_Info, State) -> {noreply, State}.
+handle_info(Info, State) ->
+    ?WARNING_MSG("Unexpected info: ~p", [Info]),
+    {noreply, State}.
 
 code_change(_OldVsn, State, _Extra) -> {ok, State}.
 
index 89dd24800345d9ebcee23a0e8cd4b375e9d8e0b1..3f8c934ab7727735589e679c20784032ec01715f 100644 (file)
@@ -136,14 +136,16 @@ handle_call({activate_stream, SHA1, Initiator, MaxConnections}, _From, State) ->
        end,
     Reply = mnesia:transaction(F),
     {reply, Reply, State};
-handle_call(_Request, _From, State) ->
-    Reply = ok,
-    {reply, Reply, State}.
+handle_call(Request, From, State) ->
+    ?WARNING_MSG("Unexpected call from ~p: ~p", [From, Request]),
+    {noreply, State}.
 
-handle_cast(_Msg, State) ->
+handle_cast(Msg, State) ->
+    ?WARNING_MSG("Unexpected cast: ~p", [Msg]),
     {noreply, State}.
 
-handle_info(_Info, State) ->
+handle_info(Info, State) ->
+    ?WARNING_MSG("Unexpected info: ~p", [Info]),
     {noreply, State}.
 
 terminate(_Reason, _State) ->
index 468c2e8c75237d865cb3e62a436480bc43f5c380..bac3911fe64c111f00566b5d161d091ba8bdec5c 100644 (file)
@@ -93,10 +93,13 @@ handle_info({route, Packet}, State) ->
                         misc:format_exception(2, Class, Reason, StackTrace)])
     end,
     {noreply, State};
-handle_info(_Info, State) -> {noreply, State}.
+handle_info(Info, State) ->
+    ?WARNING_MSG("Unexpected info: ~p", [Info]),
+    {noreply, State}.
 
-handle_call(_Request, _From, State) ->
-    {reply, ok, State}.
+handle_call(Request, From, State) ->
+    ?WARNING_MSG("Unexpected call from ~p: ~p", [From, Request]),
+    {noreply, State}.
 
 handle_cast({reload, ServerHost, NewOpts, OldOpts}, State) ->
     NewHosts = gen_mod:get_opt_hosts(NewOpts),
index c4871571834118fd120e3bd4543716d4cdbc8c55..4790b4cd34f262120dd153a8223143ed29a3ca75 100644 (file)
@@ -232,14 +232,19 @@ init([Host, Opts]) ->
 
 handle_call(get_state, _From, State) ->
     {reply, {ok, State}, State};
-handle_call(_Request, _From, State) ->
-    {reply, {error, badarg}, State}.
+handle_call(Request, From, State) ->
+    ?WARNING_MSG("Unexpected call from ~p: ~p", [From, Request]),
+    {noreply, State}.
 
 handle_cast({set_state, NewState}, _State) ->
     {noreply, NewState};
-handle_cast(_Msg, State) -> {noreply, State}.
+handle_cast(Msg, State) ->
+    ?WARNING_MSG("Unexpected cast: ~p", [Msg]),
+    {noreply, State}.
 
-handle_info(_Info, State) -> {noreply, State}.
+handle_info(Info, State) ->
+    ?WARNING_MSG("Unexpected info: ~p", [Info]),
+    {noreply, State}.
 
 terminate(_Reason, State) ->
     Host = State#state.host,
index 26a4398ea974d5b653476c1e2fea1babb3845149..0ff2623f08cdbc90a429aa16e5c87bf9dc43dd44 100644 (file)
@@ -198,11 +198,12 @@ handle_call({delete, US, CallID, CSeq}, _From, State) ->
 handle_call({ping, SIPSocket}, _From, State) ->
     Res = process_ping(SIPSocket),
     {reply, Res, State};
-handle_call(_Request, _From, State) ->
-    Reply = ok,
-    {reply, Reply, State}.
+handle_call(Request, From, State) ->
+    ?WARNING_MSG("Unexpected call from ~p: ~p", [From, Request]),
+    {noreply, State}.
 
-handle_cast(_Msg, State) ->
+handle_cast(Msg, State) ->
+    ?WARNING_MSG("Unexpected cast: ~p", [Msg]),
     {noreply, State}.
 
 handle_info({write, Sessions, Supported}, State) ->
@@ -222,8 +223,8 @@ handle_info({'DOWN', MRef, process, _Pid, _Reason}, State) ->
            ok
     end,
     {noreply, State};
-handle_info(_Info, State) ->
-    ?ERROR_MSG("Unexpected info: ~p", [_Info]),
+handle_info(Info, State) ->
+    ?WARNING_MSG("Unexpected info: ~p", [Info]),
     {noreply, State}.
 
 terminate(_Reason, _State) ->
index cd2d9a1cfbe96fcd026226665b12ac5cc88e7dc0..c5a9fc6170b4bda135e7f00f5e6ecf20f0286ee6 100644 (file)
@@ -194,14 +194,16 @@ init([Host, Opts]) ->
 
 handle_call(get_state, _From, State) ->
     {reply, {ok, State}, State};
-handle_call(_Request, _From, State) ->
-    Reply = ok,
-    {reply, Reply, State}.
+handle_call(Request, From, State) ->
+    ?WARNING_MSG("Unexpected call from ~p: ~p", [From, Request]),
+    {noreply, State}.
 
-handle_cast(_Msg, State) ->
+handle_cast(Msg, State) ->
+    ?WARNING_MSG("Unexpected cast: ~p", [Msg]),
     {noreply, State}.
 
-handle_info(_Info, State) ->
+handle_info(Info, State) ->
+    ?WARNING_MSG("Unexpected info: ~p", [Info]),
     {noreply, State}.
 
 terminate(_Reason, _State) ->
index 2c277c5da74ffe18e627cfcf54ff7db41998f1b4..72028e60a3fed39528734e7e89922294827e3e1a 100644 (file)
@@ -58,14 +58,16 @@ init([]) ->
            {stop, Reason}
     end.
 
-handle_call(_Request, _From, State) ->
-    Reply = ok,
-    {reply, Reply, State}.
+handle_call(Request, From, State) ->
+    ?WARNING_MSG("Unexpected call from ~p: ~p", [From, Request]),
+    {noreply, State}.
 
-handle_cast(_Msg, State) ->
+handle_cast(Msg, State) ->
+    ?WARNING_MSG("Unexpected cast: ~p", [Msg]),
     {noreply, State}.
 
-handle_info(_Info, State) ->
+handle_info(Info, State) ->
+    ?WARNING_MSG("Unexpected info: ~p", [Info]),
     {noreply, State}.
 
 terminate(_Reason, _State) ->