25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-20 16:15:59 +01: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"}}},
{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"}}},

View File

@ -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.