mirror of
https://github.com/containers/podman.git
synced 2025-12-15 11:42:28 +08:00
vendor: update c/storage
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
7
vendor/github.com/containers/storage/pkg/lockfile/lockfile.go
generated
vendored
7
vendor/github.com/containers/storage/pkg/lockfile/lockfile.go
generated
vendored
@@ -426,10 +426,13 @@ func (l *LockFile) lock(lType lockType) {
|
||||
// command.
|
||||
func (l *LockFile) tryLock(lType lockType) error {
|
||||
var success bool
|
||||
var rwMutexUnlocker func()
|
||||
if lType == readLock {
|
||||
success = l.rwMutex.TryRLock()
|
||||
rwMutexUnlocker = l.rwMutex.RUnlock
|
||||
} else {
|
||||
success = l.rwMutex.TryLock()
|
||||
rwMutexUnlocker = l.rwMutex.Unlock
|
||||
}
|
||||
if !success {
|
||||
return fmt.Errorf("resource temporarily unavailable")
|
||||
@@ -440,7 +443,7 @@ func (l *LockFile) tryLock(lType lockType) error {
|
||||
// If we're the first reference on the lock, we need to open the file again.
|
||||
fd, err := openLock(l.file, l.ro)
|
||||
if err != nil {
|
||||
l.rwMutex.Unlock()
|
||||
rwMutexUnlocker()
|
||||
return err
|
||||
}
|
||||
l.fd = fd
|
||||
@@ -450,7 +453,7 @@ func (l *LockFile) tryLock(lType lockType) error {
|
||||
// reader lock or a writer lock.
|
||||
if err = lockHandle(l.fd, lType, true); err != nil {
|
||||
closeHandle(fd)
|
||||
l.rwMutex.Unlock()
|
||||
rwMutexUnlocker()
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user