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