From 69a5a22810ffda701507dc88cfa03af119c3b471 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Sautret?= Date: Thu, 28 Apr 2022 14:54:41 +0200 Subject: [PATCH] Delete ping timer if resource is gone after the ping has been sent --- src/mod_ping.erl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/mod_ping.erl b/src/mod_ping.erl index da6733617..2ee5133fa 100644 --- a/src/mod_ping.erl +++ b/src/mod_ping.erl @@ -132,6 +132,14 @@ handle_cast(Msg, State) -> ?WARNING_MSG("Unexpected cast: ~p", [Msg]), {noreply, State}. +handle_info({iq_reply, #iq{type = error} = IQ, JID}, State) -> + Timers = case xmpp:get_error(IQ) of + #stanza_error{type=cancel, reason='service-unavailable'} -> + del_timer(JID, State#state.timers); + _ -> + State#state.timers + end, + {noreply, State#state{timers = Timers}}; handle_info({iq_reply, #iq{}, _JID}, State) -> {noreply, State}; handle_info({iq_reply, timeout, JID}, State) ->