diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2014-12-10 15:59:00 -0500 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2014-12-10 15:59:11 -0500 |
commit | 3e27a71c711f7408032ba2f2aa25289378232264 (patch) | |
tree | ad718152e9dfb44f0ec20e7967693f6340e12078 | |
parent | d3d0e342d4b470e141aefdddf66ef387e7890d79 (diff) |
simpler approach for Apple setrlimit() compatibility issue
-rw-r--r-- | libs/ardour/globals.cc | 28 |
1 files changed, 5 insertions, 23 deletions
diff --git a/libs/ardour/globals.cc b/libs/ardour/globals.cc index c36748612a..1ccb169bfc 100644 --- a/libs/ardour/globals.cc +++ b/libs/ardour/globals.cc @@ -214,34 +214,16 @@ lotsa_files_please () if (getrlimit (RLIMIT_NOFILE, &rl) == 0) { +#ifdef __APPLE__ + /* See the COMPATIBILITY note on the Apple setrlimit() man page */ + rl.rlim_cur = min ((rlim_t) OPEN_MAX, rl.rlim_max); +#else rl.rlim_cur = rl.rlim_max; +#endif if (setrlimit (RLIMIT_NOFILE, &rl) != 0) { if (rl.rlim_cur == RLIM_INFINITY) { -#if __APPLE__ - /* For some reason, Apple doesn't do this the - * same way as Linux, and asking for - * RLIM_INFINITY even though that is - * rl.rlim_cur doesn't work. - * - * So try some actual large numbers in the hope - * that one of them will work. - */ - - rl.rlim_cur = 10000; - if (setrlimit (RLIMIT_NOFILE, &rl) != 0) { - rl.rlim_cur = 4096; - if (setrlimit (RLIMIT_NOFILE, &rl) != 0) { - rl.rlim_cur = 1000; - if (setrlimit (RLIMIT_NOFILE, &rl) != 0) { - error << _("Could not set system open files limit to a reasonable value. Be careful!") << endmsg; - } - } - } - info << string_compose ("Configured system open file limit to %1", rl.rlim_cur) << endmsg; -#else error << _("Could not set system open files limit to \"unlimited\"") << endmsg; -#endif } else { error << string_compose (_("Could not set system open files limit to %1"), rl.rlim_cur) << endmsg; } |