25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-22 16:20:52 +01:00

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'.
This commit is contained in:
Holger Weiss 2014-09-06 20:29:02 +02:00
parent 646b445515
commit 11b2921971

View File

@ -1196,9 +1196,7 @@ session_established({xmlstreamerror, _}, StateData) ->
send_element(StateData, ?INVALID_XML_ERR), send_element(StateData, ?INVALID_XML_ERR),
send_trailer(StateData), send_trailer(StateData),
{stop, normal, StateData}; {stop, normal, StateData};
session_established(closed, StateData) session_established(closed, #state{mgmt_state = active} = StateData) ->
when StateData#state.mgmt_timeout > 0,
StateData#state.mgmt_state == active ->
fsm_next_state(wait_for_resume, StateData); fsm_next_state(wait_for_resume, StateData);
session_established(closed, StateData) -> session_established(closed, StateData) ->
{stop, normal, StateData}. {stop, normal, StateData}.
@ -1682,8 +1680,7 @@ handle_info({route, From, To,
handle_info({'DOWN', Monitor, _Type, _Object, _Info}, handle_info({'DOWN', Monitor, _Type, _Object, _Info},
_StateName, StateData) _StateName, StateData)
when Monitor == StateData#state.socket_monitor -> when Monitor == StateData#state.socket_monitor ->
if StateData#state.mgmt_timeout > 0, if StateData#state.mgmt_state == active;
StateData#state.mgmt_state == active orelse
StateData#state.mgmt_state == pending -> StateData#state.mgmt_state == pending ->
fsm_next_state(wait_for_resume, StateData); fsm_next_state(wait_for_resume, StateData);
true -> true ->
@ -2461,6 +2458,8 @@ fsm_next_state_gc(StateName, PackedStateData) ->
fsm_next_state(session_established, StateData) -> fsm_next_state(session_established, StateData) ->
{next_state, session_established, StateData, {next_state, session_established, StateData,
?C2S_HIBERNATE_TIMEOUT}; ?C2S_HIBERNATE_TIMEOUT};
fsm_next_state(wait_for_resume, #state{mgmt_timeout = 0} = StateData) ->
{stop, normal, StateData};
fsm_next_state(wait_for_resume, StateData) fsm_next_state(wait_for_resume, StateData)
when StateData#state.mgmt_state /= pending -> when StateData#state.mgmt_state /= pending ->
?INFO_MSG("Waiting for resumption of stream for ~s", ?INFO_MSG("Waiting for resumption of stream for ~s",