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

CHANGES
lib/isc/unix/resource.c

diff --git a/CHANGES b/CHANGES
index 2bb971bd12ff777cc5af1004732b5e6e0939fc58..d47916987fa0442e9a09d478a893f8a5c75a2bc2 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+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]
index aaaec1b6ffcab3820bf1e29dd7061caba18f9ffe..f422cb1876682d9021676f46f769bf232cd19e17 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: resource.c,v 1.18 2008/07/11 23:05:46 jinmei Exp $ */
+/* $Id: resource.c,v 1.19 2008/07/21 03:37:17 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
@@ -151,6 +155,17 @@ isc_resource_setlimit(isc_resource_t resource, isc_resourcevalue_t value) {
                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));
 }