Skip to content

Commit

Permalink
client: refactor setConnected(disconnected) out of conditional
Browse files Browse the repository at this point in the history
c.setConnected(disconnected) was called inconditionally in both
conditions start so it is in fact independent of the status. Move
it out.
  • Loading branch information
ptsneves committed Feb 11, 2022
1 parent 7254d2c commit e8ce195
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions client.go
Expand Up @@ -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)
Expand All @@ -479,7 +479,6 @@ func (c *client) Disconnect(quiesce uint) {
}
} else {
WARN.Println(CLI, "Disconnect() called but not connected (disconnected/reconnecting)")
c.setConnected(disconnected)
}

}
Expand Down

0 comments on commit e8ce195

Please sign in to comment.