The branch, master has been updated
       via  ac0d452ac64cae90645ad49b1bb04f2e8bf89c9b (commit)
      from  4e5997736c6e173ddfd735239ac5c77d2353a5f6 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit ac0d452ac64cae90645ad49b1bb04f2e8bf89c9b
Author: Steven Danneman <[email protected]>
Date:   Sun Feb 22 21:55:25 2009 -0800

    s3: Wrap usage of rlimit in configure checks

-----------------------------------------------------------------------

Summary of changes:
 source3/param/loadparm.c |   39 +++++++++++++++++++--------------------
 1 files changed, 19 insertions(+), 20 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index e50ab92..89c706d 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);
 }
 
 /**


-- 
Samba Shared Repository

Reply via email to