Skip to content

Commit

Permalink
Apply changes from Pull Request 1046
Browse files Browse the repository at this point in the history
  • Loading branch information
jonknight73 committed Feb 18, 2020
1 parent bd8da72 commit bda3052
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 21 deletions.
44 changes: 23 additions & 21 deletions db.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,33 +233,35 @@ func Open(opt Options) (db *DB, err error) {
if err := createDirs(opt); err != nil {
return nil, err
}
dirLockGuard, err = acquireDirectoryLock(opt.Dir, lockFile, opt.ReadOnly)
if err != nil {
return nil, err
}
defer func() {
if dirLockGuard != nil {
_ = dirLockGuard.release()
}
}()
absDir, err := filepath.Abs(opt.Dir)
if err != nil {
return nil, err
}
absValueDir, err := filepath.Abs(opt.ValueDir)
if err != nil {
return nil, err
}
if absValueDir != absDir {
valueDirLockGuard, err = acquireDirectoryLock(opt.ValueDir, lockFile, opt.ReadOnly)
if !opt.BypassLockGuard {
dirLockGuard, err = acquireDirectoryLock(opt.Dir, lockFile, opt.ReadOnly)
if err != nil {
return nil, err
}
defer func() {
if valueDirLockGuard != nil {
_ = valueDirLockGuard.release()
if dirLockGuard != nil {
_ = dirLockGuard.release()
}
}()
absDir, err := filepath.Abs(opt.Dir)
if err != nil {
return nil, err
}
absValueDir, err := filepath.Abs(opt.ValueDir)
if err != nil {
return nil, err
}
if absValueDir != absDir {
valueDirLockGuard, err = acquireDirectoryLock(opt.ValueDir, lockFile, opt.ReadOnly)
if err != nil {
return nil, err
}
defer func() {
if valueDirLockGuard != nil {
_ = valueDirLockGuard.release()
}
}()
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions options.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ type Options struct {
LogRotatesToFlush int32
ZSTDCompressionLevel int

BypassLockGuard bool

// When set, checksum will be validated for each entry read from the value log file.
VerifyValueChecksum bool

Expand Down

0 comments on commit bda3052

Please sign in to comment.