mirror of
https://github.com/etcd-io/bbolt.git
synced 2025-05-31 11:42:30 +00:00
Revert "replace unix implementation to be the same as solaris to fix an issue with glusterfs"
This reverts commit ca9f2088aab4fc9832e587655f0026875bddbf9b.
This commit is contained in:
parent
9145e04770
commit
82ecdfe9ef
24
bolt_unix.go
24
bolt_unix.go
@ -21,21 +21,16 @@ func flock(db *DB, mode os.FileMode, exclusive bool, timeout time.Duration) erro
|
|||||||
} else if timeout > 0 && time.Since(t) > timeout {
|
} else if timeout > 0 && time.Since(t) > timeout {
|
||||||
return ErrTimeout
|
return ErrTimeout
|
||||||
}
|
}
|
||||||
var lock syscall.Flock_t
|
flag := syscall.LOCK_SH
|
||||||
lock.Start = 0
|
|
||||||
lock.Len = 0
|
|
||||||
lock.Pid = 0
|
|
||||||
lock.Whence = 0
|
|
||||||
lock.Pid = 0
|
|
||||||
if exclusive {
|
if exclusive {
|
||||||
lock.Type = syscall.F_WRLCK
|
flag = syscall.LOCK_EX
|
||||||
} else {
|
|
||||||
lock.Type = syscall.F_RDLCK
|
|
||||||
}
|
}
|
||||||
err := syscall.FcntlFlock(db.file.Fd(), syscall.F_SETLK, &lock)
|
|
||||||
|
// Otherwise attempt to obtain an exclusive lock.
|
||||||
|
err := syscall.Flock(int(db.file.Fd()), flag|syscall.LOCK_NB)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return nil
|
return nil
|
||||||
} else if err != syscall.EAGAIN {
|
} else if err != syscall.EWOULDBLOCK {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,12 +41,7 @@ func flock(db *DB, mode os.FileMode, exclusive bool, timeout time.Duration) erro
|
|||||||
|
|
||||||
// funlock releases an advisory lock on a file descriptor.
|
// funlock releases an advisory lock on a file descriptor.
|
||||||
func funlock(db *DB) error {
|
func funlock(db *DB) error {
|
||||||
var lock syscall.Flock_t
|
return syscall.Flock(int(db.file.Fd()), syscall.LOCK_UN)
|
||||||
lock.Start = 0
|
|
||||||
lock.Len = 0
|
|
||||||
lock.Type = syscall.F_UNLCK
|
|
||||||
lock.Whence = 0
|
|
||||||
return syscall.FcntlFlock(uintptr(db.file.Fd()), syscall.F_SETLK, &lock)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// mmap memory maps a DB's data file.
|
// mmap memory maps a DB's data file.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user