]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
2395. [port] Avoid warning and no effect from "files unlimited"
authorMark Andrews <marka@isc.org>
Wed, 23 Jul 2008 11:30:56 +0000 (11:30 +0000)
committerMark Andrews <marka@isc.org>
Wed, 23 Jul 2008 11:30:56 +0000 (11:30 +0000)
                        on Linux when running as root. [RT #18335]

2322.   [port]          MacOS: work around the limitation of setrlimit()
                        for RLIMIT_NOFILE. [RT #17526]

CHANGES
lib/isc/unix/resource.c

diff --git a/CHANGES b/CHANGES
index 4883d3d3c817af8bfaf413ccfb8cbc9abd85ca0c..9ad0555ac5a3e8f58bed555d436cde209b3ea887 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,10 +1,16 @@
 2396.  [bug]           Don't set SO_REUSEADDR for randomized ports.
                        [RT #18336]
 
+2395.  [port]          Avoid warning and no effect from "files unlimited"
+                       on Linux when running as root. [RT #18335]
+
 2394.  [bug]           Default configuration options set the limit for
                        open files to 'unlimited' as described in the
                        documentation. [RT #18331]
 
+2322.  [port]          MacOS: work around the limitation of setrlimit()
+                       for RLIMIT_NOFILE. [RT #17526]
+
        --- 9.4.2-P1 released ---
 
 2375.   [security]      Fully randomize UDP query ports to improve
index 703ec27ae0762aba8ab881fd3ffbcf87d31c5bf8..d23bf4edc545c1a5b9e24474c68c968dfec9d9f3 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: resource.c,v 1.12 2004/03/05 05:11:46 marka Exp $ */
+/* $Id: resource.c,v 1.12.944.1 2008/07/23 11:30:56 marka Exp $ */
 
 #include <config.h>
 
 #include <isc/result.h>
 #include <isc/util.h>
 
+#ifdef __linux__
+#include <linux/fs.h>  /* To get the large NR_OPEN. */
+#endif
+
 #include "errno2result.h"
 
 static isc_result_t
@@ -182,8 +186,34 @@ isc_resource_setlimit(isc_resource_t resource, isc_resourcevalue_t value) {
 
        if (unixresult == 0)
                return (ISC_R_SUCCESS);
-       else
-               return (isc__errno2result(errno));
+
+#if defined(OPEN_MAX) && defined(__APPLE__)
+       /*
+        * The Darwin kernel doesn't accept RLIM_INFINITY for rlim_cur; the
+        * maximum possible value is OPEN_MAX.  BIND8 used to use
+        * sysconf(_SC_OPEN_MAX) for such a case, but this value is much
+        * smaller than OPEN_MAX and is not really effective.
+        */
+       if (resource == isc_resource_openfiles && rlim_value == RLIM_INFINITY) {
+               rl.rlim_cur = OPEN_MAX;
+               unixresult = setrlimit(unixresource, &rl);
+               if (unixresult == 0)
+                       return (ISC_R_SUCCESS);
+       }
+#elif defined(NR_OPEN) && defined(__linux__)
+       /*
+        * Some Linux kernels don't accept RLIM_INFINIT; the maximum
+        * possible value is the NR_OPEN defined in linux/fs.h.
+        */
+       if (resource == isc_resource_openfiles && rlim_value == RLIM_INFINITY) {
+               rl.rlim_cur = rl.rlim_max = NR_OPEN;
+               unixresult = setrlimit(unixresource, &rl);
+               if (unixresult == 0)
+                       return (ISC_R_SUCCESS);
+       }
+#endif
+
+       return (isc__errno2result(errno));
 }
 
 isc_result_t