1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-25 07:42:06 +01:00

Prevent race condition after stream resumption

New stanzas sent directly after stream resumption might have been added
to unacknowledgedStanzas before the old unacknowledged stanzas
are resent. This caused new stanzas to be sent twice and later led
to a StreamManagementCounterError.

Fixes SMACK-786
This commit is contained in:
Dmitry Deshevoy 2017-11-16 17:30:16 +03:00
parent 0da3ebf385
commit 230a226424

View file

@ -1155,8 +1155,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
if (!smSessionId.equals(resumed.getPrevId())) { if (!smSessionId.equals(resumed.getPrevId())) {
throw new StreamIdDoesNotMatchException(smSessionId, resumed.getPrevId()); throw new StreamIdDoesNotMatchException(smSessionId, resumed.getPrevId());
} }
// Mark SM as enabled and resumption as successful. // Mark SM as enabled
smResumedSyncPoint.reportSuccess();
smEnabledSyncPoint.reportSuccess(); smEnabledSyncPoint.reportSuccess();
// First, drop the stanzas already handled by the server // First, drop the stanzas already handled by the server
processHandledCount(resumed.getHandledCount()); processHandledCount(resumed.getHandledCount());
@ -1172,6 +1171,8 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
if (!stanzasToResend.isEmpty()) { if (!stanzasToResend.isEmpty()) {
requestSmAcknowledgementInternal(); requestSmAcknowledgementInternal();
} }
// Mark SM resumption as successful
smResumedSyncPoint.reportSuccess();
LOGGER.fine("Stream Management (XEP-198): Stream resumed"); LOGGER.fine("Stream Management (XEP-198): Stream resumed");
break; break;
case AckAnswer.ELEMENT: case AckAnswer.ELEMENT: