Skip to content

Commit 381a483

Browse files
committed
Fix a race condition in carboncopy_SUITE
First, remove the session using ejabberd_sm, so that stanzas are not routed to the terminating user. Only after that send the `unavailable` stanza.
1 parent 3b5713a commit 381a483

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/mod_presence.erl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,10 @@ handle_user_terminate(Acc, StateData, Presences, Reason) ->
138138
PresenceUnavailable = presence_unavailable_stanza(Status),
139139
ParamsAcc = #{from_jid => Jid, to_jid => jid:to_bare(Jid), element => PresenceUnavailable},
140140
Acc1 = mongoose_acc:update_stanza(ParamsAcc, Acc),
141+
Sid = mongoose_c2s:get_sid(StateData),
142+
Info = mongoose_c2s:get_info(StateData),
143+
ejabberd_sm:unset_presence(Acc1, Sid, Jid, Status, Info),
141144
presence_broadcast(Acc1, Presences),
142-
mongoose_hooks:unset_presence(Acc1, Jid, Status),
143145
{ok, Acc}.
144146

145147
-spec foreign_event(Acc, Params, Extra) -> Result when

0 commit comments

Comments
 (0)