Commit 6d54a6fc authored by Mark Andrews's avatar Mark Andrews
Browse files

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]
parent ee02a035
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]
......
......@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: main.c,v 1.165 2008/10/24 01:08:21 marka Exp $ */
/* $Id: main.c,v 1.166 2008/10/24 01:24:54 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>
......@@ -576,6 +577,7 @@ destroy_managers(void) {
static void
setup(void) {
isc_result_t result;
isc_resourcevalue_t old_openfiles;
#ifdef HAVE_LIBSCF
char *instance = NULL;
#endif
......@@ -691,6 +693,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.
......
......@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: os.h,v 1.27 2007/06/19 23:46:59 tbox Exp $ */
/* $Id: os.h,v 1.28 2008/10/24 01:24:54 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);
......
......@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: os.c,v 1.85 2008/10/15 05:00:57 marka Exp $ */
/* $Id: os.c,v 1.86 2008/10/24 01:24:54 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>
......@@ -570,6 +571,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
......
......@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: os.h,v 1.12 2007/06/19 23:46:59 tbox Exp $ */
/* $Id: os.h,v 1.13 2008/10/24 01:24:54 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);
......
......@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: os.c,v 1.28 2008/01/18 23:46:57 tbox Exp $ */
/* $Id: os.c,v 1.29 2008/10/24 01:24:54 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) {
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment