From ca0dfdcad027fcad4015dc243dabaec8210ae869 Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Wed, 23 Jul 2008 11:18:40 +0000 Subject: [PATCH] 2395. [port] Avoid warning and no effect from "files unlimited" on Linux when running as root. [RT #18335] --- CHANGES | 3 +++ lib/isc/unix/resource.c | 17 ++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 9bb4ad02b8..99ccd51a75 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,9 @@ 2396. [bug] Don't set SO_REUSEADDR for randomized ports. [RT #18336] +2395. [port] Avoid warning and no effect from "files unlimited" + on Linux when running as root. [RT #18335] + 2394. [bug] Default configuration options set the limit for open files to 'unlimited' as described in the documentation. [RT #18331] diff --git a/lib/isc/unix/resource.c b/lib/isc/unix/resource.c index bfec43d32d..717f079da7 100644 --- a/lib/isc/unix/resource.c +++ b/lib/isc/unix/resource.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: resource.c,v 1.11.206.3 2008/01/26 23:45:31 tbox Exp $ */ +/* $Id: resource.c,v 1.11.206.3.4.1 2008/07/23 11:18:40 marka Exp $ */ #include @@ -28,6 +28,10 @@ #include #include +#ifdef __linux__ +#include /* To get the large NR_OPEN. */ +#endif + #include "errno2result.h" static isc_result_t @@ -151,6 +155,17 @@ isc_resource_setlimit(isc_resource_t resource, isc_resourcevalue_t value) { if (unixresult == 0) return (ISC_R_SUCCESS); } +#elif defined(NR_OPEN) && defined(__linux__) + /* + * Some Linux kernels don't accept RLIM_INFINIT; the maximum + * possible value is the NR_OPEN defined in linux/fs.h. + */ + if (resource == isc_resource_openfiles && rlim_value == RLIM_INFINITY) { + rl.rlim_cur = rl.rlim_max = NR_OPEN; + unixresult = setrlimit(unixresource, &rl); + if (unixresult == 0) + return (ISC_R_SUCCESS); + } #endif return (isc__errno2result(errno)); }