diff options
author | Evgeniy Khramtsov <ekhramtsov@process-one.net> | 2018-02-15 15:42:55 +0300 |
---|---|---|
committer | Evgeniy Khramtsov <ekhramtsov@process-one.net> | 2018-02-15 15:42:55 +0300 |
commit | 52ded14b7f17abbfbe7ea91982463f12e3a2262e (patch) | |
tree | 747097e30f1c5aba4017cb99e441a2eece676c39 | |
parent | e5ba7c3f3ceed2c65fdc16bd5a1a001544f15b11 (diff) |
Update incoming stanzas counter on invalid XML
-rw-r--r-- | src/mod_stream_mgmt.erl | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/mod_stream_mgmt.erl b/src/mod_stream_mgmt.erl index d295053f5..549a15df6 100644 --- a/src/mod_stream_mgmt.erl +++ b/src/mod_stream_mgmt.erl @@ -176,7 +176,8 @@ c2s_authenticated_packet(#{mgmt_state := MgmtState} = State, Pkt) c2s_authenticated_packet(State, Pkt) -> update_num_stanzas_in(State, Pkt). -c2s_handle_recv(#{lang := Lang} = State, El, {error, Why}) -> +c2s_handle_recv(#{mgmt_state := MgmtState, + lang := Lang} = State, El, {error, Why}) -> Xmlns = xmpp:get_ns(El), IsStanza = xmpp:is_stanza(El), if Xmlns == ?NS_STREAM_MGMT_2; Xmlns == ?NS_STREAM_MGMT_3 -> @@ -185,12 +186,13 @@ c2s_handle_recv(#{lang := Lang} = State, El, {error, Why}) -> text = xmpp:mk_text(Txt, Lang), xmlns = Xmlns}, send(State, Err); - IsStanza -> + IsStanza andalso (MgmtState == pending orelse MgmtState == active) -> + State1 = update_num_stanzas_in(State, El), case xmpp:get_type(El) of - <<"result">> -> State; - <<"error">> -> State; + <<"result">> -> State1; + <<"error">> -> State1; _ -> - State#{mgmt_is_resent => false} + State1#{mgmt_is_resent => false} end; true -> State |