From bc992fea5e6ccd1cd9f92350a669f1c04747994b Mon Sep 17 00:00:00 2001 From: runner Date: Sun, 31 Jan 2016 10:05:21 +0800 Subject: [PATCH] fix munmap bug in the windows fix munmap bug in the windows fix munmap bug in the windows fix munmap bug in the windows fix munmap bug in the windows --- tsdb/engine/tsm1/mmap_windows.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tsdb/engine/tsm1/mmap_windows.go b/tsdb/engine/tsm1/mmap_windows.go index 009a9eefbf..312670a9f6 100644 --- a/tsdb/engine/tsm1/mmap_windows.go +++ b/tsdb/engine/tsm1/mmap_windows.go @@ -82,7 +82,6 @@ func mmap(f *os.File, offset int64, length int) (out []byte, err error) { // Based on: https://github.com/edsrzf/mmap-go // Based on: https://github.com/boltdb/bolt/bolt_windows.go func munmap(b []byte) (err error) { - handleLock.Lock() defer handleLock.Unlock() @@ -99,7 +98,9 @@ func munmap(b []byte) (err error) { delete(handleMap, addr) e := syscall.CloseHandle(syscall.Handle(handle)) - return os.NewSyscallError("CloseHandle", e) + if e != nil { + return os.NewSyscallError("CloseHandle", e) + } file, ok := fileMap[addr] if !ok { @@ -109,7 +110,8 @@ func munmap(b []byte) (err error) { delete(fileMap, addr) e = file.Close() - return errors.New("Close File" + e.Error()) - + if e != nil { + return errors.New("close file" + e.Error()) + } return nil }