diff --git a/src/coordinator/protobuf_client.go b/src/coordinator/protobuf_client.go index ed72f134d7..6e4cf854d7 100644 --- a/src/coordinator/protobuf_client.go +++ b/src/coordinator/protobuf_client.go @@ -186,16 +186,20 @@ func (self *ProtobufClient) reconnect() { if !swapped { return } + defer func() { + self.connectionStatus = IS_CONNECTED + }() self.Close() conn, err := net.DialTimeout("tcp", self.hostAndPort, self.writeTimeout) if err == nil { + self.connLock.Lock() + defer self.connLock.Unlock() self.conn = conn log.Info("connected to %s", self.hostAndPort) } else { log.Error("failed to connect to %s", self.hostAndPort) } - self.connectionStatus = IS_CONNECTED return }