aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--syscall.go9
-rw-r--r--syscall_linux.go10
-rw-r--r--tx.go3
3 files changed, 22 insertions, 0 deletions
diff --git a/syscall.go b/syscall.go
new file mode 100644
index 0000000..c3a1bb5
--- /dev/null
+++ b/syscall.go
@@ -0,0 +1,9 @@
+// +build !linux
+
+package bolt
+
+import "os"
+
+func fdatasync(f *os.File) error {
+ return f.Sync()
+}
diff --git a/syscall_linux.go b/syscall_linux.go
new file mode 100644
index 0000000..351b65a
--- /dev/null
+++ b/syscall_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/tx.go b/tx.go
index 5b2b14d..181444e 100644
--- a/tx.go
+++ b/tx.go
@@ -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)