From e8ce195adb9103cc1ac03e271aee93d191b14147 Mon Sep 17 00:00:00 2001 From: Paulo Neves Date: Fri, 11 Feb 2022 15:21:26 +0100 Subject: [PATCH] client: refactor setConnected(disconnected) out of conditional c.setConnected(disconnected) was called inconditionally in both conditions start so it is in fact independent of the status. Move it out. --- client.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/client.go b/client.go index e7b33ebd..135075da 100644 --- a/client.go +++ b/client.go @@ -453,11 +453,11 @@ func (c *client) attemptConnection() (net.Conn, byte, bool, error) { // `SetAutoReconnect` and/or `SetConnectRetry`options instead of implementing this yourself. func (c *client) Disconnect(quiesce uint) { defer c.disconnect() + c.setConnected(disconnected) status := atomic.LoadUint32(&c.status) if status == connected { DEBUG.Println(CLI, "disconnecting") - c.setConnected(disconnected) dm := packets.NewControlPacket(packets.Disconnect).(*packets.DisconnectPacket) dt := newToken(packets.Disconnect) @@ -479,7 +479,6 @@ func (c *client) Disconnect(quiesce uint) { } } else { WARN.Println(CLI, "Disconnect() called but not connected (disconnected/reconnecting)") - c.setConnected(disconnected) } }