]> granicus.if.org Git - ejabberd/commitdiff
Fix ping IQ reply/timeout processing ("mod_ping" regression since 17.x that may cause...
authorFrank Diebolt <frank.diebolt@al-enterprise.com>
Tue, 29 Jan 2019 17:13:28 +0000 (18:13 +0100)
committerFrank Diebolt <frank.diebolt@al-enterprise.com>
Tue, 29 Jan 2019 17:13:28 +0000 (18:13 +0100)
src/mod_ping.erl

index ffdee2f012d114b54d4a26ca38ad8d5d58e43b61..25d2b60ed6647aec81c1b987c8b990281cd48140 100644 (file)
@@ -122,30 +122,31 @@ handle_cast({start_ping, JID}, State) ->
 handle_cast({stop_ping, JID}, State) ->
     Timers = del_timer(JID, State#state.timers),
     {noreply, State#state{timers = Timers}};
-handle_cast({iq_reply, timeout, JID}, State) ->
-    ejabberd_hooks:run(user_ping_timeout, State#state.host,
-                      [JID]),
-    Timers = case State#state.timeout_action of
-                kill ->
-                    #jid{user = User, server = Server,
-                         resource = Resource} =
-                        JID,
-                    case ejabberd_sm:get_session_pid(User, Server, Resource)
-                    of
-                        Pid when is_pid(Pid) -> ejabberd_c2s:close(Pid, ping_timeout);
-                        _ -> ok
-                    end,
-                    del_timer(JID, State#state.timers);
-                _ ->
-                    State#state.timers
-            end,
-    {noreply, State#state{timers = Timers}};
-handle_cast({iq_reply, #iq{}, _JID}, State) ->
-    {noreply, State};
 handle_cast(Msg, State) ->
     ?WARNING_MSG("unexpected cast: ~p", [Msg]),
     {noreply, State}.
 
+handle_info({iq_reply, #iq{type = error}, JID}, State) ->
+    handle_info({iq_reply, timeout, JID}, State);
+handle_info({iq_reply, #iq{}, _JID}, State) ->
+    {noreply, State};
+handle_info({iq_reply, timeout, JID}, State) ->
+    Timers = del_timer(JID, State#state.timers),
+    ejabberd_hooks:run(user_ping_timeout, State#state.host,
+                      [JID]),
+    case State#state.timeout_action of
+      kill ->
+         #jid{user = User, server = Server,
+              resource = Resource} =
+             JID,
+         case ejabberd_sm:get_session_pid(User, Server, Resource)
+             of
+           Pid when is_pid(Pid) -> ejabberd_c2s:close(Pid, ping_timeout);
+           _ -> ok
+         end;
+      _ -> ok
+    end,
+    {noreply, State#state{timers = Timers}};
 handle_info({timeout, _TRef, {ping, JID}}, State) ->
     Host = State#state.host,
     From = jid:remove_resource(JID),