Skip to content

Commit

Permalink
more portable solution for Mmap/Munmap influxdata#4787
Browse files Browse the repository at this point in the history
  • Loading branch information
fazalmajid committed Nov 13, 2015
1 parent f7ab798 commit 19d3f5b
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 3 deletions.
11 changes: 11 additions & 0 deletions tsdb/engine/tsm1/mmap_plan9.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// portability wrapper for Mmap/Munmap
// +build plan9

package tsm1

import (
"golang.org/x/sys/plan9"
)

var Mmap = plan9.Mmap
var Munmap = plan9.Munmap
11 changes: 11 additions & 0 deletions tsdb/engine/tsm1/mmap_unix.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// portability wrapper for Mmap/Munmap
// +build !windows,!plan9

package tsm1

import (
"golang.org/x/sys/unix"
)

var Mmap = unix.Mmap
var Munmap = unix.Munmap
11 changes: 11 additions & 0 deletions tsdb/engine/tsm1/mmap_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// portability wrapper for Mmap/Munmap
// +build windows

package tsm1

import (
"golang.org/x/sys/windows"
)

var Mmap = windows.Mmap
var Munmap = windows.Munmap
5 changes: 2 additions & 3 deletions tsdb/engine/tsm1/tsm1.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"encoding/binary"
"encoding/json"
"fmt"
"golang.org/x/sys/unix"
"hash/fnv"
"io"
"io/ioutil"
Expand Down Expand Up @@ -1972,7 +1971,7 @@ func NewDataFile(f *os.File) (*dataFile, error) {
if err != nil {
return nil, err
}
mmap, err := unix.Mmap(int(f.Fd()), 0, int(fInfo.Size()), syscall.PROT_READ, syscall.MAP_SHARED|MAP_POPULATE)
mmap, err := Mmap(int(f.Fd()), 0, int(fInfo.Size()), syscall.PROT_READ, syscall.MAP_SHARED|MAP_POPULATE)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -2031,7 +2030,7 @@ func (d *dataFile) close() error {
if d.mmap == nil {
return nil
}
err := unix.Munmap(d.mmap)
err := Munmap(d.mmap)
if err != nil {
return err
}
Expand Down

0 comments on commit 19d3f5b

Please sign in to comment.