Merge pull request #76 from benbjohnson/fsync

fdatasync
pull/34/head
Ben Johnson 2014-03-23 10:01:58 -06:00
commit 1282a4aff7
3 changed files with 22 additions and 0 deletions

9
syscall.go Normal file
View File

@ -0,0 +1,9 @@
// +build !linux
package bolt
import "os"
func fdatasync(f *os.File) error {
return f.Sync()
}

10
syscall_linux.go Normal file
View File

@ -0,0 +1,10 @@
package bolt
import (
"os"
"syscall"
)
func fdatasync(f *os.File) error {
return syscall.Fdatasync(int(f.Fd()))
}

3
tx.go
View File

@ -329,6 +329,9 @@ func (t *Tx) write() error {
return err
}
}
if err := fdatasync(t.db.file); err != nil {
return err
}
// Clear out page cache.
t.pages = make(map[pgid]*page)