diff options
author | Ben Johnson <benbjohnson@yahoo.com> | 2014-06-22 10:10:55 -0600 |
---|---|---|
committer | Ben Johnson <benbjohnson@yahoo.com> | 2014-06-22 10:10:55 -0600 |
commit | 4f428feecc153d0cb8e4867ea15b3bf1ae6ff3f5 (patch) | |
tree | 03190de76962bf6166752f086c1abd83bb965ec3 /bolt_linux.go | |
parent | Merge pull request #209 from benbjohnson/next-seq-uint64 (diff) | |
parent | Add Open() options, flock timeout. (diff) | |
download | dedo-4f428feecc153d0cb8e4867ea15b3bf1ae6ff3f5.tar.gz dedo-4f428feecc153d0cb8e4867ea15b3bf1ae6ff3f5.tar.xz |
Merge pull request #208 from benbjohnson/open-timeout
Add Open() options, flock timeout.
Diffstat (limited to 'bolt_linux.go')
-rw-r--r-- | bolt_linux.go | 40 |
1 files changed, 0 insertions, 40 deletions
diff --git a/bolt_linux.go b/bolt_linux.go index 761a83e..7e3e539 100644 --- a/bolt_linux.go +++ b/bolt_linux.go @@ -3,7 +3,6 @@ package bolt import ( "os" "syscall" - "unsafe" ) var odirect = syscall.O_DIRECT @@ -12,42 +11,3 @@ var odirect = syscall.O_DIRECT func fdatasync(f *os.File) error { return syscall.Fdatasync(int(f.Fd())) } - -// flock acquires an advisory lock on a file descriptor. -func flock(f *os.File) error { - return syscall.Flock(int(f.Fd()), syscall.LOCK_EX) -} - -// funlock releases an advisory lock on a file descriptor. -func funlock(f *os.File) error { - return syscall.Flock(int(f.Fd()), syscall.LOCK_UN) -} - -// mmap memory maps a DB's data file. -func mmap(db *DB, sz int) error { - b, err := syscall.Mmap(int(db.file.Fd()), 0, sz, syscall.PROT_READ, syscall.MAP_SHARED) - if err != nil { - return err - } - - // Save the original byte slice and convert to a byte array pointer. - db.dataref = b - db.data = (*[maxMapSize]byte)(unsafe.Pointer(&b[0])) - db.datasz = sz - return nil -} - -// munmap unmaps a DB's data file from memory. -func munmap(db *DB) error { - // Ignore the unmap if we have no mapped data. - if db.dataref == nil { - return nil - } - - // Unmap using the original byte slice. - err := syscall.Munmap(db.dataref) - db.dataref = nil - db.data = nil - db.datasz = 0 - return err -} |