From, jid:make(USR), Packet)
end, lists:usort(Recipients)),
fsm_next_state(StateName, StateData);
+ handle_info({set_csi_state, CsiState}, StateName, StateData) ->
+ fsm_next_state(StateName, StateData#state{csi_state = CsiState});
+ handle_info({set_resume_timeout, Timeout}, StateName, StateData) ->
+ fsm_next_state(StateName, StateData#state{mgmt_timeout = Timeout});
handle_info(dont_ask_offline, StateName, StateData) ->
fsm_next_state(StateName, StateData#state{ask_offline = false});
+handle_info(close, StateName, StateData) ->
+ ?DEBUG("Timeout waiting for stream management acknowledgement of ~s",
+ [jid:to_string(StateData#state.jid)]),
+ close(self()),
+ fsm_next_state(StateName, StateData#state{mgmt_ack_timer = undefined});
handle_info({_Ref, {resume, OldStateData}}, StateName, StateData) ->
%% This happens if the resume_session/1 request timed out; the new session
%% now receives the late response.
?C2S_HIBERNATE_TIMEOUT};
fsm_next_state(wait_for_resume, #state{mgmt_timeout = 0} = StateData) ->
{stop, normal, StateData};
- fsm_next_state(wait_for_resume, #state{mgmt_pending_since = undefined} =
- StateData) ->
+ fsm_next_state(wait_for_resume, #state{mgmt_pending_since = undefined,
+ sid = SID, jid = JID, ip = IP,
+ conn = Conn, auth_module = AuthModule,
+ server = Host} = StateData) ->
+ case StateData of
+ #state{mgmt_ack_timer = undefined} ->
+ ok;
+ #state{mgmt_ack_timer = Timer} ->
+ erlang:cancel_timer(Timer)
+ end,
?INFO_MSG("Waiting for resumption of stream for ~s",
- [jid:to_string(StateData#state.jid)]),
+ [jid:to_string(JID)]),
+ Info = [{ip, IP}, {conn, Conn}, {auth_module, AuthModule}],
+ NewStateData = ejabberd_hooks:run_fold(c2s_session_pending, Host, StateData,
+ [SID, JID, Info]),
{next_state, wait_for_resume,
- StateData#state{mgmt_state = pending, mgmt_pending_since = os:timestamp()},
- StateData#state.mgmt_timeout};
+ NewStateData#state{mgmt_state = pending,
+ mgmt_pending_since = os:timestamp()},
+ NewStateData#state.mgmt_timeout};
fsm_next_state(wait_for_resume, StateData) ->
Diff = timer:now_diff(os:timestamp(), StateData#state.mgmt_pending_since),
Timeout = max(StateData#state.mgmt_timeout - Diff div 1000, 1),