aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dedo.go30
1 files changed, 3 insertions, 27 deletions
diff --git a/src/dedo.go b/src/dedo.go
index 8745584..b806fc3 100644
--- a/src/dedo.go
+++ b/src/dedo.go
@@ -189,11 +189,6 @@ type panicked struct {
// Options represents the options that can be set when opening a database.
type Options struct {
- // Timeout is the amount of time to wait to obtain a file lock.
- // When set to zero it will wait indefinitely. This option is only
- // available on Darwin and Linux.
- Timeout time.Duration
-
// Sets the DB.MmapFlags flag before memory mapping the file.
MmapFlags int
@@ -543,12 +538,6 @@ var (
// callers.
trySolo = errors.New("batch function returned an error and should be re-run solo")
- // DefaultOptions represent the options used if nil options are passed into Open().
- // No timeout is used which will cause Bolt to wait indefinitely for a lock.
- DefaultOptions = &Options{
- Timeout: 0,
- }
-
//
// These errors can be returned when opening or calling methods on a DB.
@@ -573,10 +562,6 @@ var (
// ErrChecksum is returned when either meta page checksum does not match.
ErrChecksum = errors.New("checksum error")
- // ErrTimeout is returned when a database cannot obtain an exclusive lock
- // on the data file after the timeout passed to Open().
- ErrTimeout = errors.New("timeout")
-
//
// These errors can occur when beginning or committing a Tx.
@@ -672,18 +657,10 @@ func fdatasync(db *DB) error {
// flock acquires an advisory lock on a file descriptor.
-func flock(db *DB, mode os.FileMode, timeout time.Duration) error {
+func flock(db *DB, mode os.FileMode) error {
const exclusive = true // FIXME: allow multiple processes to cooperate
- var t time.Time
for {
- // If we're beyond our timeout then return an error.
- // This can only occur after we've attempted a flock once.
- if t.IsZero() {
- t = time.Now()
- } else if timeout > 0 && time.Since(t) > timeout {
- return ErrTimeout
- }
flag := syscall.LOCK_SH
if exclusive {
flag = syscall.LOCK_EX
@@ -1862,9 +1839,8 @@ func Open(path string, mode os.FileMode, options *Options) (*DB, error) {
path: path,
}
- // Set default options if no options are provided.
if options == nil {
- options = DefaultOptions
+ options = &Options{}
}
db.MmapFlags = options.MmapFlags
@@ -1887,7 +1863,7 @@ func Open(path string, mode os.FileMode, options *Options) (*DB, error) {
// if !options.ReadOnly.
// The database file is locked using the shared lock (more than one process may
// hold a lock at the same time) otherwise (options.ReadOnly is set).
- if err := flock(db, mode, options.Timeout); err != nil {
+ if err := flock(db, mode); err != nil {
_ = db.close()
return nil, err
}