Skip to content

Commit 6d770e2

Browse files
committed
Fix for issue #726
Signed-off-by: ogis-yamazaki <Yamazaki_Shoji@ogis-ri.co.jp>
1 parent da0c59a commit 6d770e2

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

  • org.eclipse.paho.client.mqttv3/src/main/java/org/eclipse/paho/client/mqttv3/internal

org.eclipse.paho.client.mqttv3/src/main/java/org/eclipse/paho/client/mqttv3/internal/CommsReceiver.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -180,14 +180,16 @@ public void run() {
180180
catch (IOException ioe) {
181181
//@TRACE 853=Stopping due to IOException
182182
log.fine(CLASS_NAME,methodName,"853");
183-
synchronized (lifecycle) {
184-
target_state = State.STOPPED;
185-
}
186-
// An EOFException could be raised if the broker processes the
187-
// DISCONNECT and ends the socket before we complete. As such,
188-
// only shutdown the connection if we're not already shutting down.
189-
if (!clientComms.isDisconnecting()) {
190-
clientComms.shutdownConnection(token, new MqttException(MqttException.REASON_CODE_CONNECTION_LOST, ioe));
183+
if (target_state != State.STOPPED) {
184+
synchronized (lifecycle) {
185+
target_state = State.STOPPED;
186+
}
187+
// An EOFException could be raised if the broker processes the
188+
// DISCONNECT and ends the socket before we complete. As such,
189+
// only shutdown the connection if we're not already shutting down.
190+
if (!clientComms.isDisconnecting()) {
191+
clientComms.shutdownConnection(token, new MqttException(MqttException.REASON_CODE_CONNECTION_LOST, ioe));
192+
}
191193
}
192194
}
193195
finally {

0 commit comments

Comments
 (0)