+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.
+
2417. [bug] Connecting UDP sockets for outgoing queries could
unexpectedly fail with an 'address already in use'
error. [RT #18411]
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: main.c,v 1.136.18.17 2006/11/10 18:51:14 marka Exp $ */
+/* $Id: main.c,v 1.136.18.18 2008/08/21 00:03:25 jinmei Exp $ */
/*! \file */
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, ...) {
isc_commandline_errprint = ISC_FALSE;
while ((ch = isc_commandline_parse(argc, argv,
- "46c:C:d:fgi:lm:n:N:p:P:st:u:vx:")) != -1) {
+ "46c:C:d:fgi:lm:n:N:p:P:"
+ "sS:t:u:vx:")) != -1) {
switch (ch) {
case '4':
if (disable4)
/* 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;
static isc_result_t
create_managers(void) {
isc_result_t result;
+ unsigned int socks;
#ifdef ISC_PLATFORM_USETHREADS
unsigned int cpus_detected;
#endif
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) {
- PERFORMANCE OF THIS SOFTWARE.
-->
-<!-- $Id: named.docbook,v 1.7.18.12 2007/08/28 07:20:01 tbox Exp $ -->
+<!-- $Id: named.docbook,v 1.7.18.13 2008/08/21 00:03:25 jinmei Exp $ -->
<refentry id="man.named">
<refentryinfo>
<date>June 30, 2000</date>
<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>
</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>
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: socket.h,v 1.57.18.13 2008/08/01 02:00:42 jinmei Exp $ */
+/* $Id: socket.h,v 1.57.18.14 2008/08/21 00:03:25 jinmei Exp $ */
#ifndef ISC_SOCKET_H
#define ISC_SOCKET_H 1
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:
*
*\li #ISC_R_SUCCESS
*\li #ISC_R_NOMEMORY
*\li #ISC_R_UNEXPECTED
+ *\li #ISC_R_NOTIMPLEMENTED
*/
isc_result_t
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: socket.c,v 1.237.18.51 2008/08/13 23:45:34 jinmei Exp $ */
+/* $Id: socket.c,v 1.237.18.52 2008/08/21 00:03:25 jinmei Exp $ */
/*! \file */
#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.
*/
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
#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) {
isc_socket_sendtov
isc_socket_sendv
isc_socketmgr_create
+isc_socketmgr_create2
isc_socketmgr_destroy
isc_socketmgr_getmaxsockets
isc_stdio_close
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: socket.c,v 1.30.18.31 2008/08/08 06:27:56 tbox Exp $ */
+/* $Id: socket.c,v 1.30.18.32 2008/08/21 00:03:25 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
*/
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);