]> 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:18:40 +0000 (11:18 +0000)
committerMark Andrews <marka@isc.org>
Wed, 23 Jul 2008 11:18:40 +0000 (11:18 +0000)
                        on Linux when running as root. [RT #18335]

CHANGES
lib/isc/unix/resource.c

diff --git a/CHANGES b/CHANGES
index 9bb4ad02b883cd7ec58fb866881f34c678887a07..99ccd51a754ec92cfbf609f7949ff49a1c42c235 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,9 @@
 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]
index bfec43d32d4546d68870952601e5efea95a243da..717f079da7078c57673f3fb560c90d51a7649c1e 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: resource.c,v 1.11.206.3 2008/01/26 23:45:31 tbox Exp $ */
+/* $Id: resource.c,v 1.11.206.3.4.1 2008/07/23 11:18:40 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));
 }