]> granicus.if.org Git - ejabberd/commitdiff
Fix race condition when deleting c2s session record
authorEvgeny Khramtsov <ekhramtsov@process-one.net>
Tue, 30 Jul 2019 12:21:58 +0000 (15:21 +0300)
committerEvgeny Khramtsov <ekhramtsov@process-one.net>
Tue, 30 Jul 2019 12:21:58 +0000 (15:21 +0300)
src/mod_stream_mgmt.erl

index 45c30e161d36910b6569e0468f81b590c74569d9..9786304a5041e5a6d9cade2f18a7e528b8b75916 100644 (file)
@@ -276,6 +276,8 @@ c2s_closed(State, _Reason) ->
 c2s_terminated(#{mgmt_state := resumed, sid := SID, jid := JID} = State, _Reason) ->
     ?DEBUG("Closing former stream of resumed session for ~s",
           [jid:encode(JID)]),
+    {U, S, R} = jid:tolower(JID),
+    ejabberd_sm:close_session(SID, U, S, R),
     ejabberd_c2s:bounce_message_queue(SID, JID),
     {stop, State};
 c2s_terminated(#{mgmt_state := MgmtState, mgmt_stanzas_in := In,
@@ -653,7 +655,6 @@ inherit_session_state(#{user := U, server := S,
                                             mgmt_stanzas_in => NumStanzasIn,
                                             mgmt_stanzas_out => NumStanzasOut,
                                             mgmt_state => active},
-                           ejabberd_sm:close_session(OldSID, U, S, R),
                            State3 = ejabberd_c2s:open_session(State2),
                            ejabberd_c2s:stop(OldPID),
                            {ok, State3};