make madvise call optional

pull/82/head
Naoki Takano 2018-02-23 09:54:47 -08:00
parent b4364696a6
commit eda393df1e
1 changed files with 3 additions and 1 deletions

View File

@ -56,7 +56,9 @@ func mmap(db *DB, sz int) error {
}
// Advise the kernel that the mmap is accessed randomly.
if err := madvise(b, syscall.MADV_RANDOM); err != nil {
err = madvise(b, syscall.MADV_RANDOM)
if err != nil && err != syscall.ENOSYS {
// Ignore not implemented error in kernel because it still works.
return fmt.Errorf("madvise: %s", err)
}