[tcp] Set sync points before they are used, and not in init()

This commit is contained in:
Florian Schmaus 2020-06-12 18:15:24 +02:00
parent 843c8dd7fe
commit fd1b49ca8f
1 changed files with 6 additions and 9 deletions

View File

@ -364,6 +364,8 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
SmackException, IOException, InterruptedException {
// Authenticate using SASL
SSLSession sslSession = secureSocket != null ? secureSocket.getSession() : null;
streamFeaturesAfterAuthenticationReceived = false;
authenticate(username, password, config.getAuthzid(), sslSession);
// Wait for stream features after the authentication.
@ -375,6 +377,8 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
// recommends to perform stream compression before resource binding.
maybeEnableCompression();
smResumedSyncPoint = SyncPointState.initial;
smResumptionFailed = null;
if (isSmResumptionPossible()) {
smResumedSyncPoint = SyncPointState.request_sent;
sendNonza(new Resume(clientHandledStanzasCount, smSessionId));
@ -409,6 +413,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
// unacknowledgedStanzas and become duplicated on reconnect. See SMACK-706.
bindResourceAndEstablishSession(resource);
smEnabledSyncPoint = false;
if (isSmAvailable() && useSm) {
// Remove what is maybe left from previously stream managed sessions
serverHandledStanzasCount = 0;
@ -535,15 +540,6 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
initState();
}
@Override
protected void initState() {
super.initState();
streamFeaturesAfterAuthenticationReceived = compressSyncPoint = false;
smResumedSyncPoint = SyncPointState.initial;
smResumptionFailed = null;
smEnabledSyncPoint = false;
}
@Override
public void sendNonza(Nonza element) throws NotConnectedException, InterruptedException {
packetWriter.sendStreamElement(element);
@ -794,6 +790,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
// If stream compression was offered by the server and we want to use
// compression then send compression request to the server
if ((compressionHandler = maybeGetCompressionHandler(compression)) != null) {
compressSyncPoint = false;
sendNonza(new Compress(compressionHandler.getCompressionMethod()));
waitForConditionOrThrowConnectionException(() -> compressSyncPoint, "establishing stream compression");
} else {