Merge pull request #8514 from influxdata/jw-solaris

Fix building on solaris/illumos
pull/8521/head
Jason Wilder 2017-06-21 12:34:15 -06:00 committed by GitHub
commit 1e3848c180
3 changed files with 42 additions and 1 deletions

View File

@ -3,6 +3,7 @@
### Bugfixes
- [#8480](https://github.com/influxdata/influxdb/pull/8480): Change the default stats interval to 1 second instead of 10 seconds.
- [#8466](https://github.com/influxdata/influxdb/issues/8466): illumos build broken on syscall.Mmap
## v1.3.0 [unreleased]

40
pkg/mmap/mmap_solaris.go Normal file
View File

@ -0,0 +1,40 @@
// +build solaris
package mmap
import (
"os"
"syscall"
"golang.org/x/sys/unix"
)
func Map(path string) ([]byte, error) {
f, err := os.Open(path)
if err != nil {
return nil, err
}
defer f.Close()
fi, err := f.Stat()
if err != nil {
return nil, err
} else if fi.Size() == 0 {
return nil, nil
}
data, err := unix.Mmap(int(f.Fd()), 0, int(fi.Size()), syscall.PROT_READ, syscall.MAP_SHARED)
if err != nil {
return nil, err
}
return data, nil
}
// Unmap closes the memory-map.
func Unmap(data []byte) error {
if data == nil {
return nil
}
return unix.Munmap(data)
}

View File

@ -1,4 +1,4 @@
// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris
// +build darwin dragonfly freebsd linux nacl netbsd openbsd
// Copyright 2015 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style