mirror of
https://github.com/crazy-max/diun.git
synced 2025-12-21 13:23:09 +01:00
Bumps [go.etcd.io/bbolt](https://github.com/etcd-io/bbolt) from 1.3.11 to 1.4.0. - [Release notes](https://github.com/etcd-io/bbolt/releases) - [Commits](https://github.com/etcd-io/bbolt/compare/v1.3.11...v1.4.0) --- updated-dependencies: - dependency-name: go.etcd.io/bbolt dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
37 lines
699 B
Go
37 lines
699 B
Go
//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
|
|
}
|