Update core/rawdb/freezer.go

Co-authored-by: Martin Holst Swende <martin@swende.se>
This commit is contained in:
Delweng 2023-09-22 17:11:17 +08:00 committed by GitHub
parent ab93f65056
commit 30910de62d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -108,11 +108,9 @@ func NewFreezer(datadir string, namespace string, readonly bool, maxTableSize ui
// Leveldb uses LOCK as the filelock filename. To prevent the // Leveldb uses LOCK as the filelock filename. To prevent the
// name collision, we use FLOCK as the lock name. // name collision, we use FLOCK as the lock name.
lock := flock.New(flockFile) lock := flock.New(flockFile)
tryLock := func() (bool, error) { tryLock := lock.TryLock
if readonly { if readonly {
return lock.TryRLock() tryLock = lock.TryRLock
}
return lock.TryLock()
} }
if locked, err := tryLock(); err != nil { if locked, err := tryLock(); err != nil {
return nil, err return nil, err