From 2dc6c1cefa16f5fc149c2d45ff07971cb774d272 Mon Sep 17 00:00:00 2001 From: Chris Hines Date: Wed, 6 Apr 2016 20:38:51 -0400 Subject: [PATCH] Defer clearing db.path until db.close returns. The Windows version of funlock needs the db.path to delete the corresponding .lock file. --- db.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/db.go b/db.go index 501d36aa..9ae95dc9 100644 --- a/db.go +++ b/db.go @@ -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 @@ -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