Locker.Locked(): clarify that we're checking for write locks
Clarify that Locker.Locked() checks if we have a write lock, since that's what we care about whenever we check it. Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
This commit is contained in:
parent
06025caa49
commit
45b0aa27aa
|
|
@ -291,7 +291,7 @@ func (r *imageStore) Save() error {
|
|||
return errors.Wrapf(ErrStoreIsReadOnly, "not allowed to modify the image store at %q", r.imagespath())
|
||||
}
|
||||
if !r.Locked() {
|
||||
return errors.New("image store is not locked")
|
||||
return errors.New("image store is not locked for writing")
|
||||
}
|
||||
rpath := r.imagespath()
|
||||
if err := os.MkdirAll(filepath.Dir(rpath), 0700); err != nil {
|
||||
|
|
|
|||
|
|
@ -378,7 +378,7 @@ func (r *layerStore) Save() error {
|
|||
return errors.Wrapf(ErrStoreIsReadOnly, "not allowed to modify the layer store at %q", r.layerspath())
|
||||
}
|
||||
if !r.Locked() {
|
||||
return errors.New("layer store is not locked")
|
||||
return errors.New("layer store is not locked for writing")
|
||||
}
|
||||
rpath := r.layerspath()
|
||||
if err := os.MkdirAll(filepath.Dir(rpath), 0700); err != nil {
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ type Locker interface {
|
|||
// IsReadWrite() checks if the lock file is read-write
|
||||
IsReadWrite() bool
|
||||
|
||||
// Locked() checks if lock is locked
|
||||
// Locked() checks if lock is locked for writing by a thread in this process
|
||||
Locked() bool
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -139,9 +139,11 @@ func (l *lockfile) Unlock() {
|
|||
l.stateMutex.Unlock()
|
||||
}
|
||||
|
||||
// Locked checks if lockfile is locked.
|
||||
// Locked checks if lockfile is locked for writing by a thread in this process.
|
||||
func (l *lockfile) Locked() bool {
|
||||
return l.locked
|
||||
l.stateMutex.Lock()
|
||||
defer l.stateMutex.Unlock()
|
||||
return l.locked && (l.locktype == unix.F_WRLCK)
|
||||
}
|
||||
|
||||
// Touch updates the lock file with the UID of the user.
|
||||
|
|
|
|||
Loading…
Reference in New Issue