fix: synchronize DWH registry snapshots
This commit is contained in:
@@ -291,6 +291,16 @@ func (d *Dir) Names() ([]string, error) {
|
||||
// Lock opens or creates a protected 0600 lock file and acquires an exclusive
|
||||
// advisory lock. Close releases the lock and descriptor.
|
||||
func (d *Dir) Lock(name string) (*Lock, error) {
|
||||
return d.lock(name, syscall.LOCK_EX)
|
||||
}
|
||||
|
||||
// LockShared opens or creates a protected 0600 lock file and acquires a shared
|
||||
// advisory lock. Close releases the lock and descriptor.
|
||||
func (d *Dir) LockShared(name string) (*Lock, error) {
|
||||
return d.lock(name, syscall.LOCK_SH)
|
||||
}
|
||||
|
||||
func (d *Dir) lock(name string, lockMode int) (*Lock, error) {
|
||||
if err := validName(name); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -327,7 +337,7 @@ func (d *Dir) Lock(name string) (*Lock, error) {
|
||||
_ = syscall.Close(fd)
|
||||
return nil, err
|
||||
}
|
||||
if err := syscall.Flock(fd, syscall.LOCK_EX); err != nil {
|
||||
if err := syscall.Flock(fd, lockMode); err != nil {
|
||||
_ = syscall.Close(fd)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user