25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-24 16:23:40 +01:00

Don't expect that socket will be available in c2s_terminated hook

For detached connection we free socket, so let's make code account for this
(and we really need it for printing debug informations).

This makes sure we call ejabberd_sm:close_session
This commit is contained in:
Paweł Chmielowski 2022-02-02 16:19:13 +01:00
parent cae4fbb40b
commit 8824a912ef

View File

@ -285,12 +285,12 @@ process_closed(State, Reason) ->
stop_async(self()),
State#{stop_reason => Reason}.
process_terminated(#{sid := SID, socket := Socket,
jid := JID, user := U, server := S, resource := R} = State,
process_terminated(#{sid := SID, jid := JID, user := U, server := S, resource := R} = State,
Reason) ->
Status = format_reason(State, Reason),
?INFO_MSG("(~ts) Closing c2s session for ~ts: ~ts",
[xmpp_socket:pp(Socket), jid:encode(JID), Status]),
[case State of #{socket := Socket} -> xmpp_socket:pp(Socket); _ -> <<"unknown">> end,
jid:encode(JID), Status]),
Pres = #presence{type = unavailable,
from = JID,
to = jid:remove_resource(JID)},