aboutsummaryrefslogtreecommitdiff
path: root/sync_std.go
diff options
context:
space:
mode:
authorTommi Virtanen <tv@eagain.net>2014-03-22 20:45:53 -0700
committerTommi Virtanen <tv@eagain.net>2014-03-22 20:47:08 -0700
commit5ce378b046e500eadd1fb53e1b1488488488ce1f (patch)
treedc70a4ab70954fa2eed179ebfb1472c700086946 /sync_std.go
parentMerge pull request #74 from benbjohnson/cli (diff)
downloaddedo-5ce378b046e500eadd1fb53e1b1488488488ce1f.tar.gz
dedo-5ce378b046e500eadd1fb53e1b1488488488ce1f.tar.xz
Call fdatasync/fsync after writing out non-meta pages
This avoids a case where writes can be reordered so meta page is written before a page it refers to, potentially causing a corrupt database after a power loss or kernel crash.
Diffstat (limited to 'sync_std.go')
-rw-r--r--sync_std.go10
1 files changed, 10 insertions, 0 deletions
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()
+}