1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/vendor/go.etcd.io/bbolt/mlock_unix.go
Sebastiaan van Stijn 40b8495735
vendor: go.etcd.io/bbolt v1.3.6
Remove the replace rule, and use the version as specified by (indirect) dependencies:

full diff: https://github.com/etcd-io/bbolt/compare/v1.3.5...v1.3.6

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-02-14 15:54:20 +01:00

36 lines
697 B
Go

// +build !windows
package bbolt
import "golang.org/x/sys/unix"
// mlock locks memory of db file
func mlock(db *DB, fileSize int) error {
sizeToLock := fileSize
if sizeToLock > db.datasz {
// Can't lock more than mmaped slice
sizeToLock = db.datasz
}
if err := unix.Mlock(db.dataref[:sizeToLock]); err != nil {
return err
}
return nil
}
//munlock unlocks memory of db file
func munlock(db *DB, fileSize int) error {
if db.dataref == nil {
return nil
}
sizeToUnlock := fileSize
if sizeToUnlock > db.datasz {
// Can't unlock more than mmaped slice
sizeToUnlock = db.datasz
}
if err := unix.Munlock(db.dataref[:sizeToUnlock]); err != nil {
return err
}
return nil
}