common/fdlimit: fix Maximum-check to respect OPEN_MAX

This commit is contained in:
Martin Holst Swende 2019-02-11 11:21:57 +01:00
parent b4d145673b
commit db23b9547b
No known key found for this signature in database
GPG key ID: 683B438C05A5DDF0

View file

@ -14,8 +14,6 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
// +build darwin
package fdlimit
import "syscall"
@ -66,5 +64,8 @@ func Maximum() (int, error) {
if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &limit); err != nil {
return 0, err
}
if limit.Max > 10240 { // OPEN_MAX is 10240
return 10240, nil
}
return int(limit.Max), nil
}