mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-24 16:23:40 +01:00
Fix ping IQ reply/timeout processing ("mod_ping" regression since 17.x that may cause resources leakage)
This commit is contained in:
parent
23e5b3756c
commit
dd57950103
@ -122,10 +122,19 @@ 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) ->
|
||||
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]),
|
||||
Timers = case State#state.timeout_action of
|
||||
case State#state.timeout_action of
|
||||
kill ->
|
||||
#jid{user = User, server = Server,
|
||||
resource = Resource} =
|
||||
@ -134,18 +143,10 @@ handle_cast({iq_reply, timeout, JID}, State) ->
|
||||
of
|
||||
Pid when is_pid(Pid) -> ejabberd_c2s:close(Pid, ping_timeout);
|
||||
_ -> ok
|
||||
end,
|
||||
del_timer(JID, State#state.timers);
|
||||
_ ->
|
||||
State#state.timers
|
||||
end;
|
||||
_ -> ok
|
||||
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({timeout, _TRef, {ping, JID}}, State) ->
|
||||
Host = State#state.host,
|
||||
From = jid:remove_resource(JID),
|
||||
|
Loading…
Reference in New Issue
Block a user