mirror of
https://github.com/ipfs/kubo.git
synced 2026-03-01 14:28:02 +08:00
Raising FD limits was erroring when the OS's max was at the maximum signed integer value. Switched the code to using uint64 instead of int64. fixed #5495 License: MIT Signed-off-by: Rob Deutsch <rdeutschob@gmail.com>
28 lines
552 B
Go
28 lines
552 B
Go
// +build darwin linux netbsd openbsd
|
|
|
|
package util
|
|
|
|
import (
|
|
unix "gx/ipfs/QmVGjyM9i2msKvLXwh9VosCTgP4mL91kC7hDmqnwTTx6Hu/sys/unix"
|
|
)
|
|
|
|
func init() {
|
|
supportsFDManagement = true
|
|
getLimit = unixGetLimit
|
|
setLimit = unixSetLimit
|
|
}
|
|
|
|
func unixGetLimit() (uint64, uint64, error) {
|
|
rlimit := unix.Rlimit{}
|
|
err := unix.Getrlimit(unix.RLIMIT_NOFILE, &rlimit)
|
|
return rlimit.Cur, rlimit.Max, err
|
|
}
|
|
|
|
func unixSetLimit(soft uint64, max uint64) error {
|
|
rlimit := unix.Rlimit{
|
|
Cur: soft,
|
|
Max: max,
|
|
}
|
|
return unix.Setrlimit(unix.RLIMIT_NOFILE, &rlimit)
|
|
}
|