1
0
Fork 0
mirror of https://github.com/processone/ejabberd synced 2025-10-03 09:49:18 +02:00

Don't count resent stanzas

Thanks to Holger Weiß for an advise
This commit is contained in:
Evgeniy Khramtsov 2017-02-21 08:44:39 +03:00
parent 61cdee97fc
commit bbfd089b7e
2 changed files with 22 additions and 16 deletions

View file

@ -24,7 +24,7 @@
{fast_tls, ".*", {git, "https://github.com/processone/fast_tls", {tag, "1.0.10"}}}, {fast_tls, ".*", {git, "https://github.com/processone/fast_tls", {tag, "1.0.10"}}},
{stringprep, ".*", {git, "https://github.com/processone/stringprep", {tag, "1.0.7"}}}, {stringprep, ".*", {git, "https://github.com/processone/stringprep", {tag, "1.0.7"}}},
{fast_xml, ".*", {git, "https://github.com/processone/fast_xml", {tag, "1.1.20"}}}, {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"}}}, {stun, ".*", {git, "https://github.com/processone/stun", {tag, "1.0.9"}}},
{esip, ".*", {git, "https://github.com/processone/esip", {tag, "1.0.10"}}}, {esip, ".*", {git, "https://github.com/processone/esip", {tag, "1.0.10"}}},
{fast_yaml, ".*", {git, "https://github.com/processone/fast_yaml", {tag, "1.0.8"}}}, {fast_yaml, ".*", {git, "https://github.com/processone/fast_yaml", {tag, "1.0.8"}}},

View file

@ -182,21 +182,27 @@ c2s_handle_send(#{mgmt_state := MgmtState, mod := Mod,
when MgmtState == pending; MgmtState == active -> when MgmtState == pending; MgmtState == active ->
case xmpp:is_stanza(Pkt) of case xmpp:is_stanza(Pkt) of
true -> true ->
case mgmt_queue_add(State, Pkt) of Meta = xmpp:get_meta(Pkt),
#{mgmt_max_queue := exceeded} = State1 -> case maps:get(mgmt_is_resent, Meta, false) of
State2 = State1#{mgmt_resend => false}, false ->
case MgmtState of case mgmt_queue_add(State, Pkt) of
active -> #{mgmt_max_queue := exceeded} = State1 ->
Err = xmpp:serr_policy_violation( State2 = State1#{mgmt_resend => false},
<<"Too many unacked stanzas">>, Lang), case MgmtState of
send(State2, Err); active ->
_ -> Err = xmpp:serr_policy_violation(
Mod:stop(State2) <<"Too many unacked stanzas">>, Lang),
send(State2, Err);
_ ->
Mod:stop(State2)
end;
State1 when SendResult == ok ->
send_rack(State1);
State1 ->
State1
end; end;
State1 when SendResult == ok -> true ->
send_rack(State1); State
State1 ->
State1
end; end;
false -> false ->
State State
@ -482,7 +488,7 @@ resend_unacked_stanzas(#{mgmt_state := MgmtState,
queue_foldl( queue_foldl(
fun({_, Time, Pkt}, AccState) -> fun({_, Time, Pkt}, AccState) ->
NewPkt = add_resent_delay_info(AccState, Pkt, Time), NewPkt = add_resent_delay_info(AccState, Pkt, Time),
send(AccState, NewPkt) send(AccState, xmpp:put_meta(NewPkt, mgmt_is_resent, true))
end, State, Queue); end, State, Queue);
resend_unacked_stanzas(State) -> resend_unacked_stanzas(State) ->
State. State.