khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 1 | package bbolt |
| 2 | |
| 3 | import ( |
| 4 | "syscall" |
| 5 | "unsafe" |
| 6 | ) |
| 7 | |
| 8 | const ( |
| 9 | msAsync = 1 << iota // perform asynchronous writes |
| 10 | msSync // perform synchronous writes |
| 11 | msInvalidate // invalidate cached data |
| 12 | ) |
| 13 | |
| 14 | func msync(db *DB) error { |
| 15 | _, _, errno := syscall.Syscall(syscall.SYS_MSYNC, uintptr(unsafe.Pointer(db.data)), uintptr(db.datasz), msInvalidate) |
| 16 | if errno != 0 { |
| 17 | return errno |
| 18 | } |
| 19 | return nil |
| 20 | } |
| 21 | |
| 22 | func fdatasync(db *DB) error { |
| 23 | if db.data != nil { |
| 24 | return msync(db) |
| 25 | } |
| 26 | return db.file.Sync() |
| 27 | } |