Skip to content
This repository has been archived by the owner on Mar 9, 2019. It is now read-only.

Commit

Permalink
Defer clearing db.path until db.close returns.
Browse files Browse the repository at this point in the history
The Windows version of funlock needs the db.path to delete the
corresponding .lock file.
  • Loading branch information
ChrisHines committed Apr 7, 2016
1 parent 831b652 commit 2dc6c1c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions db.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ type DB struct {
path string
file *os.File
lockfile *os.File // windows only
dataref []byte // mmap'ed readonly, write throws SEGV
dataref []byte // mmap'ed readonly, write throws SEGV
data *[maxMapSize]byte
datasz int
filesz int // current on disk file size
Expand Down Expand Up @@ -383,11 +383,15 @@ func (db *DB) close() error {
if !db.opened {
return nil
}

db.opened = false

db.freelist = nil
db.path = ""

// defer clearing the path because funlock may need it.
defer func() {
db.path = ""
}()

// Clear ops.
db.ops.writeAt = nil
Expand Down

0 comments on commit 2dc6c1c

Please sign in to comment.