mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-12-22 10:37:59 +01:00
[tcp] Drop Stream Management state on clean shutdown
We previously only set the SM session ID to zero, but that is not enough. On a clean shutdown, i.e. where we send a </stream> close tag, we also have to nullify the unacknowledgedStanzas queue.
This commit is contained in:
parent
3f3590b42b
commit
49ebe8c587
1 changed files with 14 additions and 5 deletions
|
@ -540,13 +540,22 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
||||||
// If we are able to resume the stream, then don't set
|
// If we are able to resume the stream, then don't set
|
||||||
// connected/authenticated/usingTLS to false since we like behave like we are still
|
// connected/authenticated/usingTLS to false since we like behave like we are still
|
||||||
// connected (e.g. sendStanza should not throw a NotConnectedException).
|
// connected (e.g. sendStanza should not throw a NotConnectedException).
|
||||||
if (isSmResumptionPossible() && instant) {
|
if (instant) {
|
||||||
disconnectedButResumeable = true;
|
disconnectedButResumeable = isSmResumptionPossible();
|
||||||
|
if (!disconnectedButResumeable) {
|
||||||
|
// Reset the stream management session id to null, since the stream is no longer resumable. Note that we
|
||||||
|
// keep the unacknowledgedStanzas queue, because we want to resend them when we are reconnected.
|
||||||
|
smSessionId = null;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
disconnectedButResumeable = false;
|
disconnectedButResumeable = false;
|
||||||
// Reset the stream management session id to null, since if the stream is cleanly closed, i.e. sending a closing
|
|
||||||
// stream tag, there is no longer a stream to resume.
|
// Drop the stream management state if this is not an instant shutdown. We send
|
||||||
smSessionId = null;
|
// a </stream> close tag and now the stream management state is no longer valid.
|
||||||
|
// This also prevents that we will potentially (re-)send any unavailable presence we
|
||||||
|
// may have send, because it got put into the unacknowledged queue and was not acknowledged before the
|
||||||
|
// connection terminated.
|
||||||
|
dropSmState();
|
||||||
// Note that we deliberately do not reset authenticatedConnectionInitiallyEstablishedTimestamp here, so that the
|
// Note that we deliberately do not reset authenticatedConnectionInitiallyEstablishedTimestamp here, so that the
|
||||||
// information is available in the connectionClosedOnError() listeners.
|
// information is available in the connectionClosedOnError() listeners.
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue