common/fdlimit: return error if OPEN_MAX is exceeded in Raise()

This commit is contained in:
Martin Holst Swende 2019-02-11 12:33:58 +01:00
parent db23b9547b
commit 75e2910312
No known key found for this signature in database
GPG key ID: 683B438C05A5DDF0

View file

@ -1,4 +1,4 @@
// Copyright 2016 The go-ethereum Authors // Copyright 2019 The go-ethereum Authors
// This file is part of the go-ethereum library. // This file is part of the go-ethereum library.
// //
// The go-ethereum library is free software: you can redistribute it and/or modify // The go-ethereum library is free software: you can redistribute it and/or modify
@ -39,7 +39,7 @@ func Raise(max uint64) error {
// //
// OPEN_MAX is 10240 // OPEN_MAX is 10240
if limit.Cur > 10240 { if limit.Cur > 10240 {
limit.Cur = 10240 return errors.New("darwin only allows OPEN_MAX (10240) open files")
} }
if err := syscall.Setrlimit(syscall.RLIMIT_NOFILE, &limit); err != nil { if err := syscall.Setrlimit(syscall.RLIMIT_NOFILE, &limit); err != nil {
return err return err