aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeniy Khramtsov <ekhramtsov@process-one.net>2017-02-21 08:44:39 +0300
committerEvgeniy Khramtsov <ekhramtsov@process-one.net>2017-02-21 08:44:39 +0300
commitbbfd089b7e1bea321b7be65bcdf291d37950d6f0 (patch)
treed68bf002bbed9fb04acc614c95b05d506dbac9c3
parentejabberd_c2s: Don't drop 'user_send_packet' result (diff)
Don't count resent stanzas
Thanks to Holger Weiß for an advise
-rw-r--r--rebar.config2
-rw-r--r--src/mod_sm.erl36
2 files changed, 22 insertions, 16 deletions
diff --git a/rebar.config b/rebar.config
index 60f1091ea..967f2de7d 100644
--- a/rebar.config
+++ b/rebar.config
@@ -24,7 +24,7 @@
{fast_tls, ".*", {git, "https://github.com/processone/fast_tls", {tag, "1.0.10"}}},
{stringprep, ".*", {git, "https://github.com/processone/stringprep", {tag, "1.0.7"}}},
{fast_xml, ".*", {git, "https://github.com/processone/fast_xml", {tag, "1.1.20"}}},
- {xmpp, ".*", {git, "https://github.com/processone/xmpp", {tag, "1.1.6"}}},
+ {xmpp, ".*", {git, "https://github.com/processone/xmpp", "5c796d1c12eb34552c3e71dcff4cbb035735ff8d"}},
{stun, ".*", {git, "https://github.com/processone/stun", {tag, "1.0.9"}}},
{esip, ".*", {git, "https://github.com/processone/esip", {tag, "1.0.10"}}},
{fast_yaml, ".*", {git, "https://github.com/processone/fast_yaml", {tag, "1.0.8"}}},
diff --git a/src/mod_sm.erl b/src/mod_sm.erl
index 991ec74ed..bc45c8731 100644
--- a/src/mod_sm.erl
+++ b/src/mod_sm.erl
@@ -182,21 +182,27 @@ c2s_handle_send(#{mgmt_state := MgmtState, mod := Mod,
when MgmtState == pending; MgmtState == active ->
case xmpp:is_stanza(Pkt) of
true ->
- 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)
+ 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;
+ State1 when SendResult == ok ->
+ send_rack(State1);
+ State1 ->
+ State1
end;
- State1 when SendResult == ok ->
- send_rack(State1);
- State1 ->
- State1
+ true ->
+ State
end;
false ->
State
@@ -482,7 +488,7 @@ resend_unacked_stanzas(#{mgmt_state := MgmtState,
queue_foldl(
fun({_, Time, Pkt}, AccState) ->
NewPkt = add_resent_delay_info(AccState, Pkt, Time),
- send(AccState, NewPkt)
+ send(AccState, xmpp:put_meta(NewPkt, mgmt_is_resent, true))
end, State, Queue);
resend_unacked_stanzas(State) ->
State.