From a854e04d28f189115372b7c0f72bf1bfa366e493 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Mon, 8 Jun 2015 09:12:43 +0200 Subject: [PATCH] Replace shutdownInProgress with queue status --- .../jivesoftware/smack/tcp/XMPPTCPConnection.java | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java b/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java index 28d91d77c..dc07bd970 100644 --- a/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java +++ b/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java @@ -466,19 +466,11 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { shutdown(true); } - /** - * true if this connection is currently disconnecting the session by performing a - * shut down. - */ - private volatile boolean shutdownInProgress; - private void shutdown(boolean instant) { if (disconnectedButResumeable) { return; } - shutdownInProgress = true; - // First shutdown the writer, this will result in a closing stream element getting send to // the server if (packetWriter != null) { @@ -512,7 +504,6 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { // stream tag, there is no longer a stream to resume. smSessionId = null; } - shutdownInProgress = false; authenticated = false; connected = false; usingTLS = false; @@ -1125,7 +1116,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { case XmlPullParser.END_TAG: if (parser.getName().equals("stream")) { closingStreamReceived.reportSuccess(); - if (shutdownInProgress) { + if (packetWriter.queue.isShutdown()) { // We received a closing stream element *after* we initiated the // termination of the session by sending a closing stream element to // the server first @@ -1255,8 +1246,8 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { */ void shutdown(boolean instant) { instantShutdown = instant; - shutdownTimestamp = System.currentTimeMillis(); queue.shutdown(); + shutdownTimestamp = System.currentTimeMillis(); try { shutdownDone.checkIfSuccessOrWait(); }