Skip to content

Commit

Permalink
Revert "replace unix implementation to be the same as solaris to fix …
Browse files Browse the repository at this point in the history
…an issue with glusterfs"

This reverts commit ca9f208.
  • Loading branch information
benbjohnson committed Jan 31, 2017
1 parent 9145e04 commit 82ecdfe
Showing 1 changed file with 7 additions and 17 deletions.
24 changes: 7 additions & 17 deletions bolt_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
return ErrTimeout
}
var lock syscall.Flock_t
lock.Start = 0
lock.Len = 0
lock.Pid = 0
lock.Whence = 0
lock.Pid = 0
flag := syscall.LOCK_SH
if exclusive {
lock.Type = syscall.F_WRLCK
} else {
lock.Type = syscall.F_RDLCK
flag = syscall.LOCK_EX
}
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 {
return nil
} else if err != syscall.EAGAIN {
} else if err != syscall.EWOULDBLOCK {
return err
}

Expand All @@ -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.
func funlock(db *DB) error {
var lock syscall.Flock_t
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)
return syscall.Flock(int(db.file.Fd()), syscall.LOCK_UN)
}

// mmap memory maps a DB's data file.
Expand Down

0 comments on commit 82ecdfe

Please sign in to comment.