]> 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:08 +0000 (01:28 +0000)
committerMark Andrews <marka@isc.org>
Fri, 24 Oct 2008 01:28:08 +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 69d4e144e9d5f6b7e24989a48c64f2d72e6164b1..ce21191004775d5ed99da32f010633391ab46154 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 881a16acdc55857b410e35a0eb4dd5bdcaff928a..d8b0a33451387ad3cb3ddcff62b3f166eb718e52 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: main.c,v 1.136.18.20 2008/10/24 01:14:35 marka Exp $ */
+/* $Id: main.c,v 1.136.18.21 2008/10/24 01:28:08 marka Exp $ */
 
 /*! \file */
 
@@ -33,6 +33,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>
@@ -559,6 +560,7 @@ destroy_managers(void) {
 static void
 setup(void) {
        isc_result_t result;
+       isc_resourcevalue_t old_openfiles;
 #ifdef HAVE_LIBSCF
        char *instance = NULL;
 #endif
@@ -671,6 +673,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 24afdcbbcc4a65eef39ee9e113fa9aec16eefbfb..b973f6a4201f34442786da066850bb5d6d6d5b0a 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: os.h,v 1.22.18.3 2005/04/29 00:15:39 marka Exp $ */
+/* $Id: os.h,v 1.22.18.4 2008/10/24 01:28:08 marka Exp $ */
 
 #ifndef NS_OS_H
 #define NS_OS_H 1
@@ -45,12 +45,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 e19d41a804d551e594bfb3fd2a93b7a7371f98f9..f543beac10b3dbc204b3785a6d58d8d7ffb039bc 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: os.c,v 1.66.18.15 2008/01/30 05:00:03 marka Exp $ */
+/* $Id: os.c,v 1.66.18.16 2008/10/24 01:28:08 marka Exp $ */
 
 /*! \file */
 
@@ -42,6 +42,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>
@@ -533,6 +534,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 17751abcc5b10e9d84b619c7c04f7abc4cc0b858..ea967e4ab6a69956b7fd0a7194c6342f255f368f 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: os.h,v 1.9.18.1 2004/09/29 06:43:54 marka Exp $ */
+/* $Id: os.h,v 1.9.18.2 2008/10/24 01:28:08 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 132bdfaf66a2ceb19dc0bc8c0222e7c3edca8f7a..81abab75be34354d839c28698ed89b855a506275 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: os.c,v 1.20.18.7 2008/01/17 23:45:58 tbox Exp $ */
+/* $Id: os.c,v 1.20.18.8 2008/10/24 01:28:08 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) {
 }