Merge branch 'fdatasync' of https://github.com/tv42/bolt into fsync

pull/34/head
Ben Johnson 2014-03-23 09:42:21 -06:00
commit fd8a13e837
3 changed files with 23 additions and 0 deletions

10
sync_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()))
}

10
sync_std.go Normal file
View File

@ -0,0 +1,10 @@
// +build !linux
package bolt
import "os"
// Fall back to syncing metadata too.
func fdatasync(f *os.File) error {
return f.Sync()
}

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)