Skip to content

Commit

Permalink
Fix race condition found by race detector
Browse files Browse the repository at this point in the history
Signed-off-by: take-cheeze <[email protected]>
  • Loading branch information
take-cheeze committed Mar 19, 2019
1 parent ba971f1 commit 2f97ef9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,11 +344,13 @@ func (c *client) reconnect() {
sleep = time.Duration(1 * time.Second)
)

for rc != 0 && c.status != disconnected {
for rc != 0 && atomic.LoadUint32(&c.status) != disconnected {
for _, broker := range c.options.Servers {
cm := newConnectMsgFromOptions(&c.options, broker)
DEBUG.Println(CLI, "about to write new connect msg")
c.Lock()
c.conn, err = openConnection(broker, c.options.TLSConfig, c.options.ConnectTimeout, c.options.HTTPHeaders)
c.Unlock()
if err == nil {
DEBUG.Println(CLI, "socket connected to broker")
switch c.options.ProtocolVersion {
Expand Down

0 comments on commit 2f97ef9

Please sign in to comment.