1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-16 20:22:05 +01:00

Drop SM state *before* binding the resource

as otherwise <bind/> and <session/> may be duplicated on reconnect.

Fixes SMACK-706.
This commit is contained in:
Florian Schmaus 2015-12-03 13:30:44 +01:00
parent 3c74ef2fd2
commit 352e422562

View file

@ -399,8 +399,6 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
LOGGER.fine("Stream resumption failed, continuing with normal stream establishment process"); LOGGER.fine("Stream resumption failed, continuing with normal stream establishment process");
} }
bindResourceAndEstablishSession(resource);
List<Stanza> previouslyUnackedStanzas = new LinkedList<Stanza>(); List<Stanza> previouslyUnackedStanzas = new LinkedList<Stanza>();
if (unacknowledgedStanzas != null) { if (unacknowledgedStanzas != null) {
// There was a previous connection with SM enabled but that was either not resumable or // There was a previous connection with SM enabled but that was either not resumable or
@ -413,6 +411,12 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
// after the 'enable' stream element has been sent. // after the 'enable' stream element has been sent.
dropSmState(); dropSmState();
} }
// Now bind the resource. It is important to do this *after* we dropped an eventually
// existing Stream Management state. As otherwise <bind/> and <session/> may end up in
// unacknowledgedStanzas and become duplicated on reconnect. See SMACK-706.
bindResourceAndEstablishSession(resource);
if (isSmAvailable() && useSm) { if (isSmAvailable() && useSm) {
// Remove what is maybe left from previously stream managed sessions // Remove what is maybe left from previously stream managed sessions
serverHandledStanzasCount = 0; serverHandledStanzasCount = 0;