diff options
author | Ben Johnson <benbjohnson@yahoo.com> | 2014-03-23 09:42:21 -0600 |
---|---|---|
committer | Ben Johnson <benbjohnson@yahoo.com> | 2014-03-23 09:42:21 -0600 |
commit | fd8a13e837f23972abb72bb6b462e53ff7c717ae (patch) | |
tree | 724643c895e3be7f6078b2284513b78f5d07bf0a | |
parent | Merge pull request #75 from Slacken/32bit_build_fails_bucket_go_67 (diff) | |
parent | Call fdatasync/fsync after writing out non-meta pages (diff) | |
download | dedo-fd8a13e837f23972abb72bb6b462e53ff7c717ae.tar.gz dedo-fd8a13e837f23972abb72bb6b462e53ff7c717ae.tar.xz |
Merge branch 'fdatasync' of https://github.com/tv42/bolt into fsync
-rw-r--r-- | sync_linux.go | 10 | ||||
-rw-r--r-- | sync_std.go | 10 | ||||
-rw-r--r-- | tx.go | 3 |
3 files changed, 23 insertions, 0 deletions
diff --git a/sync_linux.go b/sync_linux.go new file mode 100644 index 0000000..351b65a --- /dev/null +++ b/sync_linux.go @@ -0,0 +1,10 @@ +package bolt + +import ( + "os" + "syscall" +) + +func fdatasync(f *os.File) error { + return syscall.Fdatasync(int(f.Fd())) +} diff --git a/sync_std.go b/sync_std.go new file mode 100644 index 0000000..d858b23 --- /dev/null +++ b/sync_std.go @@ -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() +} @@ -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) |