diff options
author | Jan Vorlicek <janvorli@microsoft.com> | 2017-09-19 23:48:35 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-19 23:48:35 +0200 |
commit | a94de3bc4448d3b71df515ad22d94698c235341f (patch) | |
tree | 505785c4605b15a1d810fca91e5e3b4de3415a2f /src/pal | |
parent | ebda95e5258b2e0fe1fe0c2cf66c443dba858743 (diff) | |
download | coreclr-a94de3bc4448d3b71df515ad22d94698c235341f.tar.gz coreclr-a94de3bc4448d3b71df515ad22d94698c235341f.tar.bz2 coreclr-a94de3bc4448d3b71df515ad22d94698c235341f.zip |
Fix rlimit setting of RLIM_NOFILE on OSX (#14054)
This change fixes an issue with rlimit setting of RLIM_NOFILE. The problem
is that the rlim_max that we get from getrlimit is too large and so setting
the rlimit_cur to that value fails. The OSX man page for rlimit has a compat
note about it, stating that the rlimit_cur needs to be limited to
min(OPEN_MAX, rlim_max) if one wants to set it to rlim_max.
Diffstat (limited to 'src/pal')
-rw-r--r-- | src/pal/src/file/file.cpp | 3 | ||||
-rw-r--r-- | src/pal/src/init/pal.cpp | 8 |
2 files changed, 11 insertions, 0 deletions
diff --git a/src/pal/src/file/file.cpp b/src/pal/src/file/file.cpp index 33316266f9..5db7d10ac5 100644 --- a/src/pal/src/file/file.cpp +++ b/src/pal/src/file/file.cpp @@ -3521,6 +3521,9 @@ DWORD FILEGetLastErrorFromErrno( void ) case EIO: dwRet = ERROR_WRITE_FAULT; break; + case EMFILE: + dwRet = ERROR_TOO_MANY_OPEN_FILES; + break; case ERANGE: dwRet = ERROR_BAD_PATHNAME; break; diff --git a/src/pal/src/init/pal.cpp b/src/pal/src/init/pal.cpp index 117117a8b0..37c1677f38 100644 --- a/src/pal/src/init/pal.cpp +++ b/src/pal/src/init/pal.cpp @@ -1065,6 +1065,14 @@ static BOOL INIT_IncreaseDescriptorLimit(void) // Set our soft limit for file descriptors to be the same // as the max limit. rlp.rlim_cur = rlp.rlim_max; +#ifdef __APPLE__ + // Based on compatibility note in setrlimit(2) manpage for OSX, + // trim the limit to OPEN_MAX. + if (rlp.rlim_cur > OPEN_MAX) + { + rlp.rlim_cur = OPEN_MAX; + } +#endif result = setrlimit(RLIMIT_NOFILE, &rlp); if (result != 0) { |