syswrap

package
v1.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 8, 2020 License: Apache-2.0 Imports: 5 Imported by: 6

Documentation

Overview

Package syswrap wraps syscalls (just mmap right now) in order to impose a global in-process limit on the maximum number of active mmaps.

Index

Constants

This section is empty.

Variables

View Source
var ErrMaxMapCountReached = errors.New("maximum map count reached")

Functions

func CloseFile

func CloseFile(f *os.File) error

CloseFile decrements the global count of open files and closes the file.

func Mmap

func Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, err error)

Mmap increments the global map count, and then calls syscall.Mmap. It decrements the map count and returns an error if the count was over the limit. If syscall.Mmap returns an error it also decrements the count.

func Munmap

func Munmap(b []byte) (err error)

Munmap calls sycall.Munmap, and then decrements the global map count if there was no error.

func OpenFile

func OpenFile(name string, flag int, perm os.FileMode) (file *os.File, mustClose bool, err error)

OpenFile passes the arguments along to os.OpenFile while incrementing a counter. If the counter is above the maximum, it returns mustClose true to signal the calling function that it should not keep the file open indefinitely. Files opened with this function should be closed by syswrap.CloseFile.

func SetMaxFileCount

func SetMaxFileCount(max uint64)

func SetMaxMapCount

func SetMaxMapCount(max uint64)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL