]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
2386. [func] Add warning about too small 'open files' limit.
authorTatuya JINMEI 神明達哉 <jinmei@isc.org>
Fri, 1 Aug 2008 02:12:46 +0000 (02:12 +0000)
committerTatuya JINMEI 神明達哉 <jinmei@isc.org>
Fri, 1 Aug 2008 02:12:46 +0000 (02:12 +0000)
[RT #18269]

CHANGES
bin/named/server.c
lib/isc/include/isc/resource.h
lib/isc/include/isc/socket.h
lib/isc/unix/resource.c
lib/isc/unix/socket.c
lib/isc/win32/libisc.def
lib/isc/win32/resource.c
lib/isc/win32/socket.c

diff --git a/CHANGES b/CHANGES
index 9aef729c37161fba77facbff0bb1309c00929712..480761a5c83b423b02a15b6bc9a1ee9a8ffd631e 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -32,6 +32,9 @@
 2389   [bug]           Move the "working directory writable" check to after
                        the ns_os_changeuser() call. [RT #18326]
 
+2386.  [func]          Add warning about too small 'open files' limit.
+                       [RT #18269]
+
        --- 9.3.6b1 released ---
 
 2385.  [bug]           A condition variable in socket.c could leak in
index 20be5cee0b2bb9bf2d6722a08205457e6975b737..62a680b8fdcab42718de33e208132c86a94047e3 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: server.c,v 1.339.2.15.2.81 2008/07/18 01:41:01 marka Exp $ */
+/* $Id: server.c,v 1.339.2.15.2.82 2008/08/01 02:12:46 jinmei Exp $ */
 
 #include <config.h>
 
@@ -2204,6 +2204,7 @@ load_configuration(const char *filename, ns_server_t *server,
        in_port_t listen_port, udpport_low, udpport_high;
        isc_portset_t *v4portset = NULL;
        isc_portset_t *v6portset = NULL;
+       isc_resourcevalue_t nfiles;
        int i;
 
        ns_aclconfctx_init(&aclconfctx);
@@ -2284,6 +2285,28 @@ load_configuration(const char *filename, ns_server_t *server,
         */
        set_limits(maps);
 
+       /*
+        * Check if max number of open sockets that the system allows is
+        * sufficiently large.  Failing this condition is not necessarily fatal,
+        * but may cause subsequent runtime failures for a busy recursive
+        * server.
+        */
+       result = isc_resource_getcurlimit(isc_resource_openfiles, &nfiles);
+       if (result == ISC_R_SUCCESS) {
+               unsigned int maxsocks;
+
+               result = isc_socketmgr_getmaxsockets(ns_g_socketmgr, &maxsocks);
+               if (result == ISC_R_SUCCESS &&
+                   (isc_resourcevalue_t)maxsocks > nfiles) {
+                       isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
+                                     NS_LOGMODULE_SERVER, ISC_LOG_WARNING,
+                                     "max open files "
+                                     "(%" ISC_PRINT_QUADFORMAT "u)"
+                                     " is smaller than max sockets (%u)",
+                                     nfiles, maxsocks);
+               }
+       }
+
        /*
         * Configure various server options.
         */
index 2c2a82981c564d2c98a047b3217b273c7204f326..dddd0396adf5926dd27c3188ed602ee6c635d198 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: resource.h,v 1.4.206.1 2004/03/06 08:14:47 marka Exp $ */
+/* $Id: resource.h,v 1.4.206.2 2008/08/01 02:12:46 jinmei Exp $ */
 
 #ifndef ISC_RESOURCE_H
 #define ISC_RESOURCE_H 1
@@ -79,6 +79,16 @@ isc_resource_getlimit(isc_resource_t resource, isc_resourcevalue_t *value);
  *     ISC_R_NOTIMPLEMENTED    'resource' is not a type known by the OS.
  */
 
+isc_result_t
+isc_resource_getcurlimit(isc_resource_t resource, isc_resourcevalue_t *value);
+/*%<
+ * Same as isc_resource_getlimit(), but returns the current (soft) limit. 
+ *
+ * Returns:
+ *\li  #ISC_R_SUCCESS          Success.
+ *\li  #ISC_R_NOTIMPLEMENTED   'resource' is not a type known by the OS.
+ */
+
 ISC_LANG_ENDDECLS
 
 #endif /* ISC_RESOURCE_H */
index d6a4139862c5e89c73c8b8660a0a4996178cb99b..7f35a46c8fc9783595703daf0a32afd0330d5ae4 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: socket.h,v 1.54.12.12 2008/07/23 23:36:22 marka Exp $ */
+/* $Id: socket.h,v 1.54.12.13 2008/08/01 02:12:46 jinmei Exp $ */
 
 #ifndef ISC_SOCKET_H
 #define ISC_SOCKET_H 1
@@ -703,6 +703,22 @@ isc_socketmgr_create(isc_mem_t *mctx, isc_socketmgr_t **managerp);
  *     ISC_R_UNEXPECTED
  */
 
+isc_result_t
+isc_socketmgr_getmaxsockets(isc_socketmgr_t *manager, unsigned int *nsockp);
+/*%<
+ * Returns in "*nsockp" the maximum number of sockets this manager may open.
+ *
+ * Requires:
+ *
+ *\li  '*manager' is a valid isc_socketmgr_t.
+ *\li  'nsockp' is not NULL.
+ *
+ * Returns:
+ *
+ *\li  #ISC_R_SUCCESS
+ *\li  #ISC_R_NOTIMPLEMENTED
+ */
+
 void
 isc_socketmgr_destroy(isc_socketmgr_t **managerp);
 /*
index 72db91a55ced83e46cff5217e52c03eeb6dfdcc8..ae99a94bad60bd32eeddf4d88951414a6c229f79 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: resource.c,v 1.11.206.5 2008/07/28 22:52:09 marka Exp $ */
+/* $Id: resource.c,v 1.11.206.6 2008/08/01 02:12:46 jinmei Exp $ */
 
 #include <config.h>
 
@@ -208,3 +208,20 @@ isc_resource_getlimit(isc_resource_t resource, isc_resourcevalue_t *value) {
 
        return (result);
 }
+
+isc_result_t
+isc_resource_getcurlimit(isc_resource_t resource, isc_resourcevalue_t *value) {
+       int unixresult;
+       int unixresource;
+       struct rlimit rl;
+       isc_result_t result;
+
+       result = resource2rlim(resource, &unixresource);
+       if (result == ISC_R_SUCCESS) {
+               unixresult = getrlimit(unixresource, &rl);
+               INSIST(unixresult == 0);
+               *value = rl.rlim_cur;
+       }
+
+       return (result);
+}
index 50876e293e68eb47773c6691236fd6418dd34e9c..e164bff80b9b2ecae43979a83d2879c3ca03bea5 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: socket.c,v 1.207.2.19.2.47 2008/07/24 10:14:49 fdupont Exp $ */
+/* $Id: socket.c,v 1.207.2.19.2.48 2008/08/01 02:12:46 jinmei Exp $ */
 
 #include <config.h>
 
@@ -3298,6 +3298,16 @@ free_manager:
        return (result);
 }
 
+isc_result_t
+isc_socketmgr_getmaxsockets(isc_socketmgr_t *manager, unsigned int *nsockp) {
+       REQUIRE(VALID_MANAGER(manager));
+       REQUIRE(nsockp != NULL);
+
+       *nsockp = manager->maxsocks;
+
+       return (ISC_R_SUCCESS);
+}
+
 void
 isc_socketmgr_destroy(isc_socketmgr_t **managerp) {
        isc_socketmgr_t *manager;
index ff4800efc03a3b2acf8a20b37c4f6f409b48d87f..257d0b6db11515f451cbd83eb35ec77d972bd4ee 100644 (file)
@@ -298,6 +298,7 @@ isc_ratelimiter_setpertic
 isc_ratelimiter_shutdown
 isc_region_compare
 isc_resource_getlimit
+isc_resource_getcurlimit
 isc_resource_setlimit
 isc_result_register
 isc_result_totext
@@ -362,6 +363,7 @@ isc_socket_sendtov
 isc_socket_sendv
 isc_socketmgr_create
 isc_socketmgr_destroy
+isc_socketmgr_getmaxsockets
 isc_stdio_close
 isc_stdio_flush
 isc_stdio_open
index fd76482ef6a4b998c61a1480c47e2e2668ea92cd..e04eb9fc84605c74c5a0731cc05bfe9cca9d8808 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: resource.c,v 1.2.12.6 2007/08/28 07:19:17 tbox Exp $ */
+/* $Id: resource.c,v 1.2.12.7 2008/08/01 02:12:46 jinmei Exp $ */
 
 #include <config.h>
 
@@ -65,3 +65,8 @@ isc_resource_getlimit(isc_resource_t resource, isc_resourcevalue_t *value) {
        *value = WIN32_MAX_OPEN_FILES;
        return (ISC_R_SUCCESS);
 }
+
+isc_result_t
+isc_resource_getcurlimit(isc_resource_t resource, isc_resourcevalue_t *value) {
+       return (isc_resource_getlimit(resource, value));
+}
index 51d44492acdc7e2c06c111e45e3ce6a3dfc54194..c6794dd1f4728460e0094b72749849cfd8022bea 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: socket.c,v 1.5.2.13.2.33 2008/07/24 10:14:49 fdupont Exp $ */
+/* $Id: socket.c,v 1.5.2.13.2.34 2008/08/01 02:12:46 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
@@ -2854,6 +2854,14 @@ isc_socketmgr_create(isc_mem_t *mctx, isc_socketmgr_t **managerp) {
        return (ISC_R_SUCCESS);
 }
 
+isc_result_t
+isc_socketmgr_getmaxsockets(isc_socketmgr_t *manager, unsigned int *nsockp) {
+       REQUIRE(VALID_MANAGER(manager));
+       REQUIRE(nsockp != NULL);
+
+       return (ISC_R_NOTIMPLEMENTED);
+}
+
 void
 isc_socketmgr_destroy(isc_socketmgr_t **managerp) {
        isc_socketmgr_t *manager;