diff --git a/weed/worker/client.go b/weed/worker/client.go index a90eac643..c624b073f 100644 --- a/weed/worker/client.go +++ b/weed/worker/client.go @@ -73,13 +73,13 @@ func NewGrpcAdminClient(adminAddress string, workerID string, dialOption grpc.Di // Connect establishes gRPC connection to admin server with TLS detection func (c *GrpcAdminClient) Connect() error { - c.mutex.Lock() - defer c.mutex.Unlock() + c.mutex.RLock() if c.connected { + c.mutex.RUnlock() return fmt.Errorf("already connected") } - + c.mutex.RUnlock() // Always start the reconnection loop, even if initial connection fails go c.reconnectionLoop()