From 1b7fae064adc4ab4c6f27d71aa02ebb19ec10172 Mon Sep 17 00:00:00 2001 From: Amos Jeffries Date: Sat, 21 May 2011 01:38:40 +1200 Subject: [PATCH] Docs: display WARNING and ERROR when max_filedescriptors has failed. The big cases of missing OS dependencies and use of select() are mentioned on configure parse where relevant. As well as from setMaxFD(). Failures to make the change are already logged, but now highlighted as ERROR cases. --- src/cache_cf.cc | 10 ++++++++++ src/tools.cc | 11 ++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/cache_cf.cc b/src/cache_cf.cc index 236ad5af9b..7796b15273 100644 --- a/src/cache_cf.cc +++ b/src/cache_cf.cc @@ -645,6 +645,16 @@ configDoConfigure(void) if (Config.errHtmlText == NULL) Config.errHtmlText = xstrdup(null_string); +#if !HAVE_SETRLIMIT || !defined(RLIMIT_NOFILE) + if (Config.max_filedescriptors > 0) { + debugs(0, DBG_WARNING, "WARNING: max_filedescriptors disabled. Operating System setrlimit(RLIMIT_NOFILE) is missing."); + } +#elif USE_SELECT || USE_SELECT_WIN32 + if (Config.max_filedescriptors > FD_SETSIZE) { + debugs(0, DBG_WARNING, "WARNING: max_filedescriptors limited to " << FD_SETSIZE << " by select() algorithm."); + } +#endif + storeConfigure(); snprintf(ThisCache, sizeof(ThisCache), "%s (%s)", diff --git a/src/tools.cc b/src/tools.cc index e98d4e7ded..257b286423 100644 --- a/src/tools.cc +++ b/src/tools.cc @@ -981,24 +981,25 @@ setMaxFD(void) } else if (Config.max_filedescriptors > 0) { #if USE_SELECT || USE_SELECT_WIN32 /* select() breaks if this gets set too big */ - if (Config.max_filedescriptors > FD_SETSIZE) + if (Config.max_filedescriptors > FD_SETSIZE) { rl.rlim_cur = FD_SETSIZE; - else + debugs(50, DBG_CRITICAL, "WARNING: 'max_filedescriptors " << Config.max_filedescriptors << "' does not work with select()"); + } else #endif rl.rlim_cur = Config.max_filedescriptors; if (rl.rlim_cur > rl.rlim_max) rl.rlim_max = rl.rlim_cur; if (setrlimit(RLIMIT_NOFILE, &rl)) { - debugs(50, DBG_CRITICAL, "setrlimit: RLIMIT_NOFILE: " << xstrerror()); + debugs(50, DBG_CRITICAL, "ERROR: setrlimit: RLIMIT_NOFILE: " << xstrerror()); getrlimit(RLIMIT_NOFILE, &rl); rl.rlim_cur = rl.rlim_max; if (setrlimit(RLIMIT_NOFILE, &rl)) { - debugs(50, DBG_CRITICAL, "setrlimit: RLIMIT_NOFILE: " << xstrerror()); + debugs(50, DBG_CRITICAL, "ERROR: setrlimit: RLIMIT_NOFILE: " << xstrerror()); } } } if (getrlimit(RLIMIT_NOFILE, &rl) < 0) { - debugs(50, DBG_CRITICAL, "setrlimit: RLIMIT_NOFILE: " << xstrerror()); + debugs(50, DBG_CRITICAL, "ERROR: getrlimit: RLIMIT_NOFILE: " << xstrerror()); } else { Squid_MaxFD = rl.rlim_cur; } -- 2.47.2