From 11b292197198c347f4c36bf6108e16191eae2acd Mon Sep 17 00:00:00 2001 From: Holger Weiss Date: Sat, 6 Sep 2014 20:29:02 +0200 Subject: [PATCH] XEP-0198: Let fsm_next_state/2 check timeout value Don't force the fsm_next_state/2 caller to check for 'mgmt_timeout = 0'. --- src/ejabberd_c2s.erl | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/ejabberd_c2s.erl b/src/ejabberd_c2s.erl index ee2934045..822edc0c9 100644 --- a/src/ejabberd_c2s.erl +++ b/src/ejabberd_c2s.erl @@ -1196,9 +1196,7 @@ session_established({xmlstreamerror, _}, StateData) -> send_element(StateData, ?INVALID_XML_ERR), send_trailer(StateData), {stop, normal, StateData}; -session_established(closed, StateData) - when StateData#state.mgmt_timeout > 0, - StateData#state.mgmt_state == active -> +session_established(closed, #state{mgmt_state = active} = StateData) -> fsm_next_state(wait_for_resume, StateData); session_established(closed, StateData) -> {stop, normal, StateData}. @@ -1682,8 +1680,7 @@ handle_info({route, From, To, handle_info({'DOWN', Monitor, _Type, _Object, _Info}, _StateName, StateData) when Monitor == StateData#state.socket_monitor -> - if StateData#state.mgmt_timeout > 0, - StateData#state.mgmt_state == active orelse + if StateData#state.mgmt_state == active; StateData#state.mgmt_state == pending -> fsm_next_state(wait_for_resume, StateData); true -> @@ -2461,6 +2458,8 @@ fsm_next_state_gc(StateName, PackedStateData) -> fsm_next_state(session_established, StateData) -> {next_state, session_established, StateData, ?C2S_HIBERNATE_TIMEOUT}; +fsm_next_state(wait_for_resume, #state{mgmt_timeout = 0} = StateData) -> + {stop, normal, StateData}; fsm_next_state(wait_for_resume, StateData) when StateData#state.mgmt_state /= pending -> ?INFO_MSG("Waiting for resumption of stream for ~s",