aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHolger Weiss <holger@zedat.fu-berlin.de>2014-05-27 21:14:49 +0200
committerHolger Weiss <holger@zedat.fu-berlin.de>2014-05-27 21:14:49 +0200
commit50a4c5a6ab4dbe62655571fba1d74f07d9f29288 (patch)
tree38c2ec7198ad793f380406e39b006ccfbea84b3c
parentMerge pull request #220 from weiss/handle-send-failure (diff)
XEP-0198: Cosmetic change: Simplify state change
When the FSM goes into the 'wait_for_resume' state, let fsm_next_state/2 take care of updating #state.mgmt_state and of writing the log line. This doesn't change the behavior, but simplifies the code.
-rw-r--r--src/ejabberd_c2s.erl21
1 files changed, 7 insertions, 14 deletions
diff --git a/src/ejabberd_c2s.erl b/src/ejabberd_c2s.erl
index 6aebefdd6..8a634b21f 100644
--- a/src/ejabberd_c2s.erl
+++ b/src/ejabberd_c2s.erl
@@ -1171,8 +1171,7 @@ session_established({xmlstreamerror, _}, StateData) ->
session_established(closed, StateData)
when StateData#state.mgmt_timeout > 0,
StateData#state.mgmt_state == active ->
- log_pending_state(StateData),
- fsm_next_state(wait_for_resume, StateData#state{mgmt_state = pending});
+ fsm_next_state(wait_for_resume, StateData);
session_established(closed, StateData) ->
{stop, normal, StateData}.
@@ -1658,9 +1657,7 @@ handle_info({'DOWN', Monitor, _Type, _Object, _Info},
if StateData#state.mgmt_timeout > 0,
StateData#state.mgmt_state == active orelse
StateData#state.mgmt_state == pending ->
- log_pending_state(StateData),
- fsm_next_state(wait_for_resume,
- StateData#state{mgmt_state = pending});
+ fsm_next_state(wait_for_resume, StateData);
true ->
{stop, normal, StateData}
end;
@@ -2436,10 +2433,12 @@ 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_pending_since = undefined} =
- StateData) ->
+fsm_next_state(wait_for_resume, StateData)
+ when StateData#state.mgmt_state /= pending ->
+ ?INFO_MSG("Waiting for resumption of stream for ~s",
+ [jlib:jid_to_string(StateData#state.jid)]),
{next_state, wait_for_resume,
- StateData#state{mgmt_pending_since = os:timestamp()},
+ StateData#state{mgmt_state = pending, mgmt_pending_since = os:timestamp()},
StateData#state.mgmt_timeout};
fsm_next_state(wait_for_resume, StateData) ->
Diff = timer:now_diff(os:timestamp(), StateData#state.mgmt_pending_since),
@@ -2806,12 +2805,6 @@ limit_queue_length(#state{jid = JID,
StateData
end.
-log_pending_state(StateData) when StateData#state.mgmt_state /= pending ->
- ?INFO_MSG("Waiting for resumption of stream for ~s",
- [jlib:jid_to_string(StateData#state.jid)]);
-log_pending_state(_StateData) ->
- ok.
-
handle_unacked_stanzas(StateData, F)
when StateData#state.mgmt_state == active;
StateData#state.mgmt_state == pending ->