aboutsummaryrefslogtreecommitdiff
path: root/bolt_linux.go
diff options
context:
space:
mode:
authorBen Johnson <benbjohnson@yahoo.com>2014-06-21 14:44:22 -0600
committerBen Johnson <benbjohnson@yahoo.com>2014-06-21 14:44:28 -0600
commit00ee0da5289dd5aaf9263ee39c8082ff3a9557c7 (patch)
treeeb405a03d008ee600d3d59ac2fe657caf397eabe /bolt_linux.go
parentMerge pull request #206 from Shopify/pending_page_stats (diff)
downloaddedo-00ee0da5289dd5aaf9263ee39c8082ff3a9557c7.tar.gz
dedo-00ee0da5289dd5aaf9263ee39c8082ff3a9557c7.tar.xz
Add Open() options, flock timeout.
This commit changes Open() to provide an additional Options argument. The options argument currently only has a Timeout which will cause the Open() to return ErrTimeout if a file lock cannot be obtained in time. Fixes #207.
Diffstat (limited to 'bolt_linux.go')
-rw-r--r--bolt_linux.go40
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
-}