diff options
author | Daniel Gultsch <daniel@gultsch.de> | 2016-06-22 12:21:33 +0200 |
---|---|---|
committer | Daniel Gultsch <daniel@gultsch.de> | 2016-06-22 12:21:33 +0200 |
commit | 34454ef2ecf22910a6d4da2e3c895b2cd8c0f76d (patch) | |
tree | dfea0ab12488144d9ee0e01ae06a80f061f365bc | |
parent | 4d1640d6ff26bc23482301396b37bae0d52e018c (diff) |
synchronize stanza count increment and write
-rw-r--r-- | src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java index e553a067..26d079f0 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java @@ -1024,9 +1024,9 @@ public class XmppConnection implements Runnable { smVersion = 2; } if (smVersion != 0) { - final EnablePacket enable = new EnablePacket(smVersion); - tagWriter.writeStanzaAsync(enable); synchronized (this.mStanzaQueue) { + final EnablePacket enable = new EnablePacket(smVersion); + tagWriter.writeStanzaAsync(enable); stanzasSent = 0; mStanzaQueue.clear(); } @@ -1261,18 +1261,18 @@ public class XmppConnection implements Runnable { disconnect(true); return; } - tagWriter.writeStanzaAsync(packet); - if (packet instanceof AbstractAcknowledgeableStanza) { - AbstractAcknowledgeableStanza stanza = (AbstractAcknowledgeableStanza) packet; - synchronized (this.mStanzaQueue) { + synchronized (this.mStanzaQueue) { + tagWriter.writeStanzaAsync(packet); + if (packet instanceof AbstractAcknowledgeableStanza) { + AbstractAcknowledgeableStanza stanza = (AbstractAcknowledgeableStanza) packet; ++stanzasSent; this.mStanzaQueue.append(stanzasSent, stanza); - } - if (stanza instanceof MessagePacket && stanza.getId() != null && getFeatures().sm()) { - if (Config.EXTENDED_SM_LOGGING) { - Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": requesting ack for message stanza #" + stanzasSent); + if (stanza instanceof MessagePacket && stanza.getId() != null && getFeatures().sm()) { + if (Config.EXTENDED_SM_LOGGING) { + Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": requesting ack for message stanza #" + stanzasSent); + } + tagWriter.writeStanzaAsync(new RequestPacket(this.smVersion)); } - tagWriter.writeStanzaAsync(new RequestPacket(this.smVersion)); } } } |