mirror of
https://github.com/minio/minio.git
synced 2025-01-11 15:03:22 -05:00
parent
f5e1b3d09e
commit
7c061fa3b6
@ -18,7 +18,10 @@
|
||||
|
||||
package sys
|
||||
|
||||
import "syscall"
|
||||
import (
|
||||
"runtime"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
// GetMaxOpenFileLimit - returns maximum file descriptor number that can be opened by this process.
|
||||
func GetMaxOpenFileLimit() (curLimit, maxLimit uint64, err error) {
|
||||
@ -33,6 +36,13 @@ func GetMaxOpenFileLimit() (curLimit, maxLimit uint64, err error) {
|
||||
|
||||
// SetMaxOpenFileLimit - sets maximum file descriptor number that can be opened by this process.
|
||||
func SetMaxOpenFileLimit(curLimit, maxLimit uint64) error {
|
||||
if runtime.GOOS == "darwin" && curLimit > 10240 {
|
||||
// The max file limit is 10240, even though
|
||||
// the max returned by Getrlimit is 1<<63-1.
|
||||
// This is OPEN_MAX in sys/syslimits.h.
|
||||
// refer https://github.com/golang/go/issues/30401
|
||||
curLimit = 10240
|
||||
}
|
||||
rlimit := syscall.Rlimit{Cur: curLimit, Max: maxLimit}
|
||||
return syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rlimit)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user