]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
2473. [port] linux: raise the limit on open files to the possible
authorMark Andrews <marka@isc.org>
Fri, 24 Oct 2008 01:28:55 +0000 (01:28 +0000)
committerMark Andrews <marka@isc.org>
Fri, 24 Oct 2008 01:28:55 +0000 (01:28 +0000)
                        maximum value before spawning threads; 'files'
                        specified in named.conf doesn't seem to work with
                        threads as expected. [RT #18784]

CHANGES
bin/named/main.c
bin/named/unix/include/named/os.h
bin/named/unix/os.c
bin/named/win32/include/named/os.h
bin/named/win32/os.c

diff --git a/CHANGES b/CHANGES
index 73521e3dbe926754dd3c9728271f27b12719d999..03981287ad1f4a3f589daebc3b0c294da8309a93 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,8 @@
+2473.  [port]          linux: raise the limit on open files to the possible
+                       maximum value before spawning threads; 'files'
+                       specified in named.conf doesn't seem to work with
+                       threads as expected. [RT #18784]
+
 2472.  [port]          linux: check the number of available cpu's before
                        calling chroot as it depends on "/proc". [RT #16923]
 
index 1f4a6199adb1c928a5e6efb23a4ccfceeffeedae..11a56c9ba88a3456af991f1a04a9474245aa0236 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: main.c,v 1.119.2.3.2.28 2008/10/24 01:14:51 marka Exp $ */
+/* $Id: main.c,v 1.119.2.3.2.29 2008/10/24 01:28:55 marka Exp $ */
 
 #include <config.h>
 
@@ -31,6 +31,7 @@
 #include <isc/hash.h>
 #include <isc/os.h>
 #include <isc/platform.h>
+#include <isc/print.h>
 #include <isc/resource.h>
 #include <isc/stdio.h>
 #include <isc/string.h>
@@ -548,6 +549,7 @@ destroy_managers(void) {
 static void
 setup(void) {
        isc_result_t result;
+       isc_resourcevalue_t old_openfiles;
 #ifdef HAVE_LIBSCF
        char *instance = NULL;
 #endif
@@ -660,6 +662,23 @@ setup(void) {
        (void)isc_resource_getlimit(isc_resource_openfiles,
                                    &ns_g_initopenfiles);
 
+       /*
+        * System resources cannot effectively be tuned on some systems.
+        * Raise the limit in such cases for safety.
+        */
+       old_openfiles = ns_g_initopenfiles;
+       ns_os_adjustnofile();
+       (void)isc_resource_getlimit(isc_resource_openfiles,
+                                   &ns_g_initopenfiles);
+       if (old_openfiles != ns_g_initopenfiles) {
+               isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
+                             NS_LOGMODULE_MAIN, ISC_LOG_NOTICE,
+                             "adjusted limit on open files from "
+                             "%" ISC_PRINT_QUADFORMAT "u to "
+                             "%" ISC_PRINT_QUADFORMAT "u",
+                             old_openfiles, ns_g_initopenfiles);
+       }
+
        /*
         * If the named configuration filename is relative, prepend the current
         * directory's name before possibly changing to another directory.
index 1c4bec0707272f8cd6ddcfda72b23ab0e22b0b31..fb604993b852924432635b67b31fc0a6832654ef 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: os.h,v 1.14.2.2.8.12 2007/08/28 07:19:08 tbox Exp $ */
+/* $Id: os.h,v 1.14.2.2.8.13 2008/10/24 01:28:55 marka Exp $ */
 
 #ifndef NS_OS_H
 #define NS_OS_H 1
@@ -43,12 +43,14 @@ ns_os_inituserinfo(const char *username);
 void
 ns_os_changeuser(void);
 
+void
+ns_os_adjustnofile(void);
+
 void
 ns_os_minprivs(void);
 
 void
 ns_os_writepidfile(const char *filename, isc_boolean_t first_time);
-
 void
 ns_os_shutdown(void);
 
index 7db048cf60bfa2767c707e2b700ab6ca6b339353..06f0f4cb4e01aa4c3e9448776126807fc5aa2c6c 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: os.c,v 1.46.2.4.8.31 2008/04/28 03:37:18 marka Exp $ */
+/* $Id: os.c,v 1.46.2.4.8.32 2008/10/24 01:28:55 marka Exp $ */
 
 #include <config.h>
 #include <stdarg.h>
@@ -40,6 +40,7 @@
 #include <isc/buffer.h>
 #include <isc/file.h>
 #include <isc/print.h>
+#include <isc/resource.h>
 #include <isc/result.h>
 #include <isc/strerror.h>
 #include <isc/string.h>
@@ -531,6 +532,24 @@ ns_os_changeuser(void) {
 #endif
 }
 
+void
+ns_os_adjustnofile() {
+#ifdef HAVE_LINUXTHREADS
+       isc_result_t result;
+       isc_resourcevalue_t newvalue;
+
+       /*
+        * Linux: max number of open files specified by one thread doesn't seem
+        * to apply to other threads on Linux.
+        */
+       newvalue = ISC_RESOURCE_UNLIMITED;
+
+       result = isc_resource_setlimit(isc_resource_openfiles, newvalue);
+       if (result != ISC_R_SUCCESS)
+               ns_main_earlywarning("couldn't adjust limit on open files");
+#endif 
+}
+
 void
 ns_os_minprivs(void) {
 #ifdef HAVE_SYS_PRCTL_H
index ce0d4f626d12f28bc27e259c50049493aac5885e..978685d63ede3d94cc3e0e3dd29e5074cea8cd4b 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: os.h,v 1.1.2.2.8.13 2007/08/28 07:19:08 tbox Exp $ */
+/* $Id: os.h,v 1.1.2.2.8.14 2008/10/24 01:28:55 marka Exp $ */
 
 #ifndef NS_OS_H
 #define NS_OS_H 1
@@ -43,6 +43,9 @@ ns_os_inituserinfo(const char *username);
 void
 ns_os_changeuser(void);
 
+void
+ns_os_adjustnofile(void);
+
 void
 ns_os_minprivs(void);
 
index 57f4b00bd8126d7dc02183d7324e94022f9d8e8f..a97a8e5b1857d847228a6b1f46cbb6ef020bdf4b 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: os.c,v 1.5.2.3.8.18 2008/01/17 23:45:27 tbox Exp $ */
+/* $Id: os.c,v 1.5.2.3.8.19 2008/10/24 01:28:55 marka Exp $ */
 
 #include <config.h>
 #include <stdarg.h>
@@ -165,6 +165,10 @@ void
 ns_os_changeuser(void) {
 }
 
+void
+ns_os_adjustnofile(void) {
+}
+
 void
 ns_os_minprivs(void) {
 }