Skip to content
This repository has been archived by the owner on Apr 24, 2023. It is now read-only.
/ jdk20 Public archive

Commit

Permalink
8300055: [BACKOUT] OPEN_MAX is no longer the max limit on macOS >= 10…
Browse files Browse the repository at this point in the history
….6 for RLIMIT_NOFILE

Reviewed-by: tschatzl, rriggs
  • Loading branch information
Gerard Ziemski committed Jan 13, 2023
1 parent 4b92fb0 commit e008146
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions src/hotspot/os/bsd/os_bsd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1969,18 +1969,15 @@ jint os::init_2(void) {
log_info(os)("os::init_2 getrlimit failed: %s", os::strerror(errno));
} else {
nbr_files.rlim_cur = nbr_files.rlim_max;
status = setrlimit(RLIMIT_NOFILE, &nbr_files);

#ifdef __APPLE__
if (status != 0 && errno == EINVAL) {
// On macOS >= 10.6 if we define _DARWIN_UNLIMITED_STREAMS or _DARWIN_C_SOURCE
// (we define _DARWIN_C_SOURCE) we can ask for RLIM_INFINITY,
// however, on macOS < 10.6 Darwin returns RLIM_INFINITY for rlim_max,
// but fails with EINVAL if you attempt to use RLIM_INFINITY.
// As per setrlimit(2), OPEN_MAX must be used instead.
nbr_files.rlim_cur = MIN(OPEN_MAX, nbr_files.rlim_cur);
status = setrlimit(RLIMIT_NOFILE, &nbr_files);
}
#endif // __APPLE__
// Darwin returns RLIM_INFINITY for rlim_max, but fails with EINVAL if
// you attempt to use RLIM_INFINITY. As per setrlimit(2), OPEN_MAX must
// be used instead
nbr_files.rlim_cur = MIN(OPEN_MAX, nbr_files.rlim_cur);
#endif

status = setrlimit(RLIMIT_NOFILE, &nbr_files);
if (status != 0) {
log_info(os)("os::init_2 setrlimit failed: %s", os::strerror(errno));
}
Expand Down

1 comment on commit e008146

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.