Commit 13d9b8ce authored by Tatuya JINMEI 神明達哉's avatar Tatuya JINMEI 神明達哉
Browse files

2420. [func] Add new command line option '-S' for named to specify

			the max number of sockets. [RT #18493]
			Use caution: this option may not work for some
			operating systems without rebuilding named.
parent 0cb666ec
2420. [func] Add new command line option '-S' for named to specify
the max number of sockets. [RT #18493]
Use caution: this option may not work for some
operating systems without rebuilding named.
2419. [cleanup] Document that isc_socket_create() and isc_socket_open()
should not be used for isc_sockettype_fdwatch sockets.
[RT #18521]
......@@ -41,10 +46,6 @@
2406. [bug] Sockets could be closed too early, leading to
inconsistent states in the socket module. [RT #18298]
xxxx. [bug] Connecting UDP sockets for outgoing queries could
unexpectedly fail with an 'address already in use'
error.
2405. [cleanup] The default value for dnssec-validation was changed to
"yes" in 9.5.0-P1 and all subsequent releases; this
was inadvertently omitted from CHANGES at the time.
......
......@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: main.c,v 1.162 2008/04/03 23:14:52 jinmei Exp $ */
/* $Id: main.c,v 1.163 2008/08/20 23:57:59 jinmei Exp $ */
/*! \file */
......@@ -85,6 +85,7 @@ static char program_name[ISC_DIR_NAMEMAX] = "named";
static char absolute_conffile[ISC_DIR_PATHMAX];
static char saved_command_line[512];
static char version[512];
static unsigned int maxsocks = 0;
void
ns_main_earlywarning(const char *format, ...) {
......@@ -356,7 +357,8 @@ parse_command_line(int argc, char *argv[]) {
isc_commandline_errprint = ISC_FALSE;
while ((ch = isc_commandline_parse(argc, argv,
"46c:C:d:fgi:lm:n:N:p:P:st:T:u:vx:")) != -1) {
"46c:C:d:fgi:lm:n:N:p:P:"
"sS:t:T:u:vx:")) != -1) {
switch (ch) {
case '4':
if (disable4)
......@@ -435,6 +437,10 @@ parse_command_line(int argc, char *argv[]) {
/* XXXRTH temporary syntax */
want_stats = ISC_TRUE;
break;
case 'S':
maxsocks = parse_int(isc_commandline_argument,
"max number of sockets");
break;
case 't':
/* XXXJAB should we make a copy? */
ns_g_chrootdir = isc_commandline_argument;
......@@ -479,6 +485,7 @@ parse_command_line(int argc, char *argv[]) {
static isc_result_t
create_managers(void) {
isc_result_t result;
unsigned int socks;
#ifdef ISC_PLATFORM_USETHREADS
unsigned int cpus_detected;
#endif
......@@ -510,13 +517,19 @@ create_managers(void) {
return (ISC_R_UNEXPECTED);
}
result = isc_socketmgr_create(ns_g_mctx, &ns_g_socketmgr);
result = isc_socketmgr_create2(ns_g_mctx, &ns_g_socketmgr, maxsocks);
if (result != ISC_R_SUCCESS) {
UNEXPECTED_ERROR(__FILE__, __LINE__,
"isc_socketmgr_create() failed: %s",
isc_result_totext(result));
return (ISC_R_UNEXPECTED);
}
result = isc_socketmgr_getmaxsockets(ns_g_socketmgr, &socks);
if (result == ISC_R_SUCCESS) {
isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
NS_LOGMODULE_SERVER,
ISC_LOG_INFO, "using up to %u sockets", socks);
}
result = isc_entropy_create(ns_g_mctx, &ns_g_entropy);
if (result != ISC_R_SUCCESS) {
......
......@@ -18,7 +18,7 @@
- PERFORMANCE OF THIS SOFTWARE.
-->
<!-- $Id: named.docbook,v 1.19 2007/06/19 06:58:03 marka Exp $ -->
<!-- $Id: named.docbook,v 1.20 2008/08/20 23:57:59 jinmei Exp $ -->
<refentry id="man.named">
<refentryinfo>
<date>June 30, 2000</date>
......@@ -64,6 +64,7 @@
<arg><option>-n <replaceable class="parameter">#cpus</replaceable></option></arg>
<arg><option>-p <replaceable class="parameter">port</replaceable></option></arg>
<arg><option>-s</option></arg>
<arg><option>-S <replaceable class="parameter">#max-socks</replaceable></option></arg>
<arg><option>-t <replaceable class="parameter">directory</replaceable></option></arg>
<arg><option>-u <replaceable class="parameter">user</replaceable></option></arg>
<arg><option>-v</option></arg>
......@@ -214,6 +215,33 @@
</listitem>
</varlistentry>
<varlistentry>
<term>-S <replaceable class="parameter">#max-socks</replaceable></term>
<listitem>
<para>
Allow <command>named</command> to use up to
<replaceable class="parameter">#max-socks</replaceable> sockets.
</para>
<warning>
<para>
This option should be unnecessary for the vast majority
of users.
The use of this option could even be harmful because the
specified value may exceed the limitation of the
underlying system API.
It is therefore set only when the default configuration
causes exhaustion of file descriptors and the
operational environment is known to support the
specified number of sockets.
Note also that the actual maximum number is normally a little
fewer than the specified value because
<command>named</command> reserves some file descriptors
for its internal use.
</para>
</warning>
</listitem>
</varlistentry>
<varlistentry>
<term>-t <replaceable class="parameter">directory</replaceable></term>
<listitem>
......
......@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: socket.h,v 1.82 2008/08/20 06:16:05 marka Exp $ */
/* $Id: socket.h,v 1.83 2008/08/20 23:57:59 jinmei Exp $ */
#ifndef ISC_SOCKET_H
#define ISC_SOCKET_H 1
......@@ -753,8 +753,15 @@ isc_socket_sendto2(isc_socket_t *sock, isc_region_t *region,
isc_result_t
isc_socketmgr_create(isc_mem_t *mctx, isc_socketmgr_t **managerp);
isc_result_t
isc_socketmgr_create2(isc_mem_t *mctx, isc_socketmgr_t **managerp,
unsigned int maxsocks);
/*%<
* Create a socket manager.
* Create a socket manager. If "maxsocks" is non-zero, it specifies the
* maximum number of sockets that the created manager should handle.
* isc_socketmgr_create() is equivalent of isc_socketmgr_create2() with
* "maxsocks" being zero.
*
* Notes:
*
......@@ -775,6 +782,7 @@ isc_socketmgr_create(isc_mem_t *mctx, isc_socketmgr_t **managerp);
*\li #ISC_R_SUCCESS
*\li #ISC_R_NOMEMORY
*\li #ISC_R_UNEXPECTED
*\li #ISC_R_NOTIMPLEMENTED
*/
isc_result_t
......
......@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: socket.c,v 1.300 2008/08/20 06:16:05 marka Exp $ */
/* $Id: socket.c,v 1.301 2008/08/20 23:57:59 jinmei Exp $ */
/*! \file */
......@@ -140,16 +140,14 @@ struct isc_socketwait {
#ifdef USE_SELECT
/*%
* Mac OS X needs a special definition to support larger values in select()
* Mac OS X needs a special definition to support larger values in select().
* We always define this because a larger value can be specified run-time.
*/
#if ISC_SOCKET_MAXSOCKETS > FD_SETSIZE
#ifdef __APPLE__
#define _DARWIN_UNLIMITED_SELECT
#endif /* __APPLE__ */
#endif /* ISC_SOCKET_MAXSOCKETS > FD_SETSIZE */
#endif /* USE_SELECT */
/*%
* Size of per-FD lock buckets.
*/
......@@ -3475,6 +3473,13 @@ cleanup_watcher(isc_mem_t *mctx, isc_socketmgr_t *manager) {
isc_result_t
isc_socketmgr_create(isc_mem_t *mctx, isc_socketmgr_t **managerp) {
return (isc_socketmgr_create2(mctx, managerp, 0));
}
isc_result_t
isc_socketmgr_create2(isc_mem_t *mctx, isc_socketmgr_t **managerp,
unsigned int maxsocks)
{
int i;
isc_socketmgr_t *manager;
#ifdef ISC_PLATFORM_USETHREADS
......@@ -3486,19 +3491,26 @@ isc_socketmgr_create(isc_mem_t *mctx, isc_socketmgr_t **managerp) {
#ifndef ISC_PLATFORM_USETHREADS
if (socketmgr != NULL) {
/* Don't allow maxsocks to be updated */
if (maxsocks > 0 && socketmgr->maxsocks != maxsocks)
return (ISC_R_EXISTS);
socketmgr->refs++;
*managerp = socketmgr;
return (ISC_R_SUCCESS);
}
#endif /* ISC_PLATFORM_USETHREADS */
if (maxsocks == 0)
maxsocks = ISC_SOCKET_MAXSOCKETS;
manager = isc_mem_get(mctx, sizeof(*manager));
if (manager == NULL)
return (ISC_R_NOMEMORY);
/* zero-clear so that necessary cleanup on failure will be easy */
memset(manager, 0, sizeof(*manager));
manager->maxsocks = ISC_SOCKET_MAXSOCKETS;
manager->maxsocks = maxsocks;
manager->fds = isc_mem_get(mctx,
manager->maxsocks * sizeof(isc_socket_t *));
if (manager->fds == NULL) {
......
......@@ -420,6 +420,7 @@ isc_socket_sendtov
isc_socket_sendv
isc_socket_setname
isc_socketmgr_create
isc_socketmgr_create2
isc_socketmgr_destroy
isc_socketmgr_getmaxsockets
isc_stdio_close
......
......@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: socket.c,v 1.65 2008/08/20 06:16:05 marka Exp $ */
/* $Id: socket.c,v 1.66 2008/08/20 23:57:59 jinmei Exp $ */
/* This code has been rewritten to take advantage of Windows Sockets
* I/O Completion Ports and Events. I/O Completion Ports is ONLY
......@@ -2906,12 +2906,22 @@ event_wait(void *uap) {
*/
isc_result_t
isc_socketmgr_create(isc_mem_t *mctx, isc_socketmgr_t **managerp) {
return (isc_socketmgr_create2(mctx, managerp, maxsocks));
}
isc_result_t
isc_socketmgr_create2(isc_mem_t *mctx, isc_socketmgr_t **managerp,
unsigned int maxsocks)
{
isc_socketmgr_t *manager;
events_thread_t *evthread = NULL;
isc_result_t result;
REQUIRE(managerp != NULL && *managerp == NULL);
if (maxsocks != 0)
return (ISC_R_NOTIMPLEMENTED);
manager = isc_mem_get(mctx, sizeof(*manager));
if (manager == NULL)
return (ISC_R_NOMEMORY);
......
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