aboutsummaryrefslogtreecommitdiff
path: root/src/ejabberd_c2s.erl
diff options
context:
space:
mode:
authorHolger Weiss <holger@zedat.fu-berlin.de>2020-06-01 21:33:55 +0200
committerHolger Weiss <holger@zedat.fu-berlin.de>2020-06-01 21:33:55 +0200
commitcd336369a5691da8289574f402fa2311b6dc027c (patch)
tree07da7d2552d60b7ba4f43e60e608e8e2e790bbce /src/ejabberd_c2s.erl
parentTest 23.0 version (diff)
mod_stream_mgmt: Don't kill new PID on resumption
During XEP-0198 resumption, the ejabberd_c2s process that handles the new connection reopens the ejabberd_sm session of the old one. Since commit b4770815c0b0416c21d01507d2908f94c25b3097, the new process adds the new session table entry before the old process removes the old one. While adding the new one, ejabberd_sm checks for old sessions to replace. This check assumes old SIDs compare lower than new ones. This assumption didn't necessarily hold for the session resumption case, where the old SID's timestamp was copied over to the new SID and only the PID was updated. Therefore, the new process was killed if the new PID happened to be smaller than the old one. Fix this by having mod_stream_mgmt use its own SM-ID rather than copying over the old SID's timestamp to the new SID. Thanks to Thilo Molitor and Friedrich Altheide for reporting the issue, and to Thomas Leister for his help with debugging it.
Diffstat (limited to '')
-rw-r--r--src/ejabberd_c2s.erl8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/ejabberd_c2s.erl b/src/ejabberd_c2s.erl
index c88221e27..92517c92a 100644
--- a/src/ejabberd_c2s.erl
+++ b/src/ejabberd_c2s.erl
@@ -180,10 +180,9 @@ host_down(Host) ->
%% Copies content of one c2s state to another.
%% This is needed for session migration from one pid to another.
-spec copy_state(state(), state()) -> state().
-copy_state(#{owner := Owner} = NewState,
- #{jid := JID, resource := Resource, sid := {Time, _},
- auth_module := AuthModule, lserver := LServer,
- pres_a := PresA} = OldState) ->
+copy_state(NewState,
+ #{jid := JID, resource := Resource, auth_module := AuthModule,
+ lserver := LServer, pres_a := PresA} = OldState) ->
State1 = case OldState of
#{pres_last := Pres, pres_timestamp := PresTS} ->
NewState#{pres_last => Pres, pres_timestamp => PresTS};
@@ -193,7 +192,6 @@ copy_state(#{owner := Owner} = NewState,
Conn = get_conn_type(State1),
State2 = State1#{jid => JID, resource => Resource,
conn => Conn,
- sid => {Time, Owner},
auth_module => AuthModule,
pres_a => PresA},
ejabberd_hooks:run_fold(c2s_copy_session, LServer, State2, [OldState]).