mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-26 17:38:45 +01:00
Merge pull request #222 from weiss/keep-session-on-failed-resume
XEP-0198: Don't drop session on failed resume
This commit is contained in:
commit
4d1332c30f
@ -1311,8 +1311,8 @@ handle_sync_event(get_subscribed, _From, StateName,
|
||||
StateData) ->
|
||||
Subscribed = (?SETS):to_list(StateData#state.pres_f),
|
||||
{reply, Subscribed, StateName, StateData};
|
||||
handle_sync_event(resume_session, _From, _StateName,
|
||||
StateData) ->
|
||||
handle_sync_event({resume_session, Time}, _From, _StateName,
|
||||
StateData) when element(1, StateData#state.sid) == Time ->
|
||||
%% The old session should be closed before the new one is opened, so we do
|
||||
%% this here instead of leaving it to the terminate callback
|
||||
ejabberd_sm:close_session(StateData#state.sid,
|
||||
@ -1320,6 +1320,9 @@ handle_sync_event(resume_session, _From, _StateName,
|
||||
StateData#state.server,
|
||||
StateData#state.resource),
|
||||
{stop, normal, {ok, StateData}, StateData#state{mgmt_state = resumed}};
|
||||
handle_sync_event({resume_session, _Time}, _From, StateName,
|
||||
StateData) ->
|
||||
{reply, {error, <<"Previous session not found">>}, StateName, StateData};
|
||||
handle_sync_event(_Event, _From, StateName,
|
||||
StateData) ->
|
||||
Reply = ok, fsm_reply(Reply, StateName, StateData).
|
||||
@ -2891,8 +2894,8 @@ inherit_session_state(#state{user = U, server = S} = StateData, ResumeID) ->
|
||||
{error, <<"Previous session PID not found">>};
|
||||
OldPID ->
|
||||
OldSID = {Time, OldPID},
|
||||
case catch resume_session(OldPID) of
|
||||
{ok, #state{sid = OldSID} = OldStateData} ->
|
||||
case catch resume_session(OldSID) of
|
||||
{ok, OldStateData} ->
|
||||
NewSID = {Time, self()}, % Old time, new PID
|
||||
Priority = case OldStateData#state.pres_last of
|
||||
undefined ->
|
||||
@ -2924,6 +2927,8 @@ inherit_session_state(#state{user = U, server = S} = StateData, ResumeID) ->
|
||||
mgmt_stanzas_in = OldStateData#state.mgmt_stanzas_in,
|
||||
mgmt_stanzas_out = OldStateData#state.mgmt_stanzas_out,
|
||||
mgmt_state = active}};
|
||||
{error, Msg} ->
|
||||
{error, Msg};
|
||||
_ ->
|
||||
{error, <<"Cannot grab session state">>}
|
||||
end
|
||||
@ -2932,8 +2937,8 @@ inherit_session_state(#state{user = U, server = S} = StateData, ResumeID) ->
|
||||
{error, <<"Invalid 'previd' value">>}
|
||||
end.
|
||||
|
||||
resume_session(FsmRef) ->
|
||||
(?GEN_FSM):sync_send_all_state_event(FsmRef, resume_session, 3000).
|
||||
resume_session({Time, PID}) ->
|
||||
(?GEN_FSM):sync_send_all_state_event(PID, {resume_session, Time}, 3000).
|
||||
|
||||
make_resume_id(StateData) ->
|
||||
{Time, _} = StateData#state.sid,
|
||||
|
Loading…
Reference in New Issue
Block a user