aboutsummaryrefslogtreecommitdiff
path: root/src/mod_stream_mgmt.erl
diff options
context:
space:
mode:
authorEvgeniy Khramtsov <ekhramtsov@process-one.net>2017-02-21 12:38:03 +0300
committerEvgeniy Khramtsov <ekhramtsov@process-one.net>2017-02-21 12:38:03 +0300
commit6ffd5ffd0ce3577988618a1198905c4d9faab9cf (patch)
treea087b437caad93af8c8067608f6efc3040f51b12 /src/mod_stream_mgmt.erl
parentImprove stream management tests (diff)
Test stream management queue overload
Diffstat (limited to 'src/mod_stream_mgmt.erl')
-rw-r--r--src/mod_stream_mgmt.erl24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/mod_stream_mgmt.erl b/src/mod_stream_mgmt.erl
index 3ec3eb72a..981b357b7 100644
--- a/src/mod_stream_mgmt.erl
+++ b/src/mod_stream_mgmt.erl
@@ -180,22 +180,17 @@ c2s_handle_recv(State, _, _) ->
c2s_handle_send(#{mgmt_state := MgmtState, mod := Mod,
lang := Lang} = State, Pkt, SendResult)
when MgmtState == pending; MgmtState == active ->
- case xmpp:is_stanza(Pkt) of
- true ->
+ case Pkt of
+ _ when ?is_stanza(Pkt) ->
Meta = xmpp:get_meta(Pkt),
case maps:get(mgmt_is_resent, Meta, false) of
false ->
case mgmt_queue_add(State, Pkt) of
#{mgmt_max_queue := exceeded} = State1 ->
State2 = State1#{mgmt_resend => false},
- case MgmtState of
- active ->
- Err = xmpp:serr_policy_violation(
- <<"Too many unacked stanzas">>, Lang),
- send(State2, Err);
- _ ->
- Mod:stop(State2)
- end;
+ Err = xmpp:serr_policy_violation(
+ <<"Too many unacked stanzas">>, Lang),
+ send(State2, Err);
State1 when SendResult == ok ->
send_rack(State1);
State1 ->
@@ -204,7 +199,14 @@ c2s_handle_send(#{mgmt_state := MgmtState, mod := Mod,
true ->
State
end;
- false ->
+ #stream_error{} ->
+ case MgmtState of
+ active ->
+ State;
+ pending ->
+ Mod:stop(State#{stop_reason => {stream, {out, Pkt}}})
+ end;
+ _ ->
State
end;
c2s_handle_send(State, _Pkt, _Result) ->