diff options
author | Christian Schneppe <christian@pix-art.de> | 2018-02-10 17:31:55 +0100 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2018-02-10 17:31:55 +0100 |
commit | 38eba12ddc215cb30c83f613f1d5543b61f36f74 (patch) | |
tree | fe262fb9c8fa961d783b119fcbb042b6c818c275 /src/main/java | |
parent | 08d42436a9f6d5d269220f01580b2b7f2c30ee58 (diff) |
SM saftey checks
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/de/pixart/messenger/xmpp/XmppConnection.java | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java b/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java index c6b913677..f7c80d841 100644 --- a/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java +++ b/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java @@ -639,7 +639,7 @@ public class XmppConnection implements Runnable { ArrayList<AbstractAcknowledgeableStanza> failedStanzas = new ArrayList<>(); synchronized (this.mStanzaQueue) { final int serverCount = Integer.parseInt(h); - if (serverCount != stanzasSent) { + if (serverCount < stanzasSent) { Log.d(Config.LOGTAG, account.getJid().toBareJid().toString() + ": session resumed with lost packages"); stanzasSent = serverCount; @@ -727,6 +727,9 @@ public class XmppConnection implements Runnable { } private void acknowledgeStanzaUpTo(int serverCount) { + if (serverCount > stanzasSent) { + Log.e(Config.LOGTAG, "server acknowledged more stanzas than we sent. serverCount=" + serverCount + ", ourCount=" + stanzasSent); + } for (int i = 0; i < mStanzaQueue.size(); ++i) { if (serverCount >= mStanzaQueue.keyAt(i)) { if (Config.EXTENDED_SM_LOGGING) { @@ -1079,6 +1082,7 @@ public class XmppConnection implements Runnable { resetAttemptCount(true); resetStreamId(); clearIqCallbacks(); + this.stanzasSent = 0; mStanzaQueue.clear(); this.redirectionUrl = null; synchronized (this.disco) { @@ -1431,6 +1435,12 @@ public class XmppConnection implements Runnable { tagWriter.writeStanzaAsync(packet); if (packet instanceof AbstractAcknowledgeableStanza) { AbstractAcknowledgeableStanza stanza = (AbstractAcknowledgeableStanza) packet; + if (this.mStanzaQueue.size() != 0) { + int currentHighestKey = this.mStanzaQueue.keyAt(this.mStanzaQueue.size() - 1); + if (currentHighestKey != stanzasSent) { + throw new AssertionError("Stanza count messed up"); + } + } ++stanzasSent; this.mStanzaQueue.append(stanzasSent, stanza); if (stanza instanceof MessagePacket && stanza.getId() != null && getFeatures().sm()) { |