diff options
author | Steven Danneman <steven.danneman@isilon.com> | 2009-02-22 21:55:25 -0800 |
---|---|---|
committer | Steven Danneman <steven.danneman@isilon.com> | 2009-02-22 22:32:27 -0800 |
commit | ac0d452ac64cae90645ad49b1bb04f2e8bf89c9b (patch) | |
tree | cee796aa9c9f333897362d8c81196c9c5ccb71fd /source3/param | |
parent | 4e5997736c6e173ddfd735239ac5c77d2353a5f6 (diff) | |
download | samba-ac0d452ac64cae90645ad49b1bb04f2e8bf89c9b.tar.gz samba-ac0d452ac64cae90645ad49b1bb04f2e8bf89c9b.tar.bz2 samba-ac0d452ac64cae90645ad49b1bb04f2e8bf89c9b.zip |
s3: Wrap usage of rlimit in configure checks
Diffstat (limited to 'source3/param')
-rw-r--r-- | source3/param/loadparm.c | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c index e50ab929ad..89c706d874 100644 --- a/source3/param/loadparm.c +++ b/source3/param/loadparm.c @@ -4656,32 +4656,31 @@ static void init_printer_values(struct service *pService) static int max_open_files(void) { int sysctl_max = MAX_OPEN_FILES; - struct rlimit rl; - bool sysctl_worked = false, rlimit_worked = false; + int rlimit_max = MAX_OPEN_FILES; #ifdef HAVE_SYSCTLBYNAME - size_t size = sizeof(sysctl_max); - if (sysctlbyname("kern.maxfilesperproc", &sysctl_max, &size, NULL,0)==0) - sysctl_worked = true; + { + size_t size = sizeof(sysctl_max); + sysctlbyname("kern.maxfilesperproc", &sysctl_max, &size, NULL, + 0); + } #endif - if (getrlimit(RLIMIT_NOFILE, &rl) == 0) - rlimit_worked = true; +#if (defined(HAVE_GETRLIMIT) && defined(RLIMIT_NOFILE)) + { + struct rlimit rl = {}; - if (sysctl_worked) { - if ((!rlimit_worked) || - (rl.rlim_cur == RLIM_INFINITY) || - (rl.rlim_cur > sysctl_max)) - return sysctl_max; - else - return rl.rlim_cur; - } else { - if ((!rlimit_worked) || - (rl.rlim_cur == RLIM_INFINITY)) - return MAX_OPEN_FILES; - else - return rl.rlim_cur; + if (getrlimit(RLIMIT_NOFILE, &rl) == 0) + rlimit_max = rl.rlim_cur; + +#if defined(RLIM_INFINITY) + if(rl.rlim_cur == RLIM_INFINITY) + rlimit_max = MAX_OPEN_FILES; } +#endif +#endif + + return MIN(sysctl_max, rlimit_max); } /** |