From: Christophe Romain Date: Tue, 13 Sep 2016 12:29:14 +0000 (+0200) Subject: Merge branch 'push-requirements' of https://github.com/weiss/ejabberd into weiss... X-Git-Tag: 16.09^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c39501a48de597e7c03086865e613b3b6e0c2625;p=ejabberd Merge branch 'push-requirements' of https://github.com/weiss/ejabberd into weiss-push-requirements --- c39501a48de597e7c03086865e613b3b6e0c2625 diff --cc src/ejabberd_c2s.erl index 1bcb77e7f,73cc57247..226c5e0da --- a/src/ejabberd_c2s.erl +++ b/src/ejabberd_c2s.erl @@@ -1766,13 -1769,12 +1792,17 @@@ handle_info({broadcast, Type, From, Pac 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. @@@ -2493,19 -2495,19 +2523,25 @@@ fsm_next_state(session_established, Sta ?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),