--------------------- PatchSet 11517 Date: 2007/06/28 23:22:01 Author: hno Branch: HEAD Tag: (none) Log: max_filedescriptor config option Since Squid-2.6 no longer really has any hardcoded filedescriptor limitations it makes sense to have a squid.conf directive allowing the number of filedescriptors to be tuned runtime. Default if unset is to obey whatever ulimit settings as before. Members: src/cf.data.pre:1.401->1.402 src/structs.h:1.516->1.517 src/tools.c:1.253->1.254 Index: squid/src/cf.data.pre =================================================================== RCS file: /cvsroot/squid/squid/src/cf.data.pre,v retrieving revision 1.401 retrieving revision 1.402 diff -u -r1.401 -r1.402 --- squid/src/cf.data.pre 25 Jun 2007 23:06:19 -0000 1.401 +++ squid/src/cf.data.pre 28 Jun 2007 23:22:01 -0000 1.402 @@ -1,6 +1,6 @@ # -# $Id: cf.data.pre,v 1.401 2007/06/25 23:06:19 hno Exp $ +# $Id: cf.data.pre,v 1.402 2007/06/28 23:22:01 hno Exp $ # # SQUID Web Proxy Cache http://www.squid-cache.org/ # ---------------------------------------------------------- @@ -5091,4 +5091,16 @@ or response to be rejected. DOC_END +NAME: max_filedescriptors +TYPE: int +DEFAULT: 0 +LOC: Config.max_filedescriptors +DOC_START + The maximum number of filedescriptors supported. + + The default "0" means Squid inherits the current ulimit setting. + + Note: Changing this requires a restart of Squid. Also + not all comm loops supports values larger than --with-maxfd. +DOC_END EOF Index: squid/src/structs.h =================================================================== RCS file: /cvsroot/squid/squid/src/structs.h,v retrieving revision 1.516 retrieving revision 1.517 diff -u -r1.516 -r1.517 --- squid/src/structs.h 25 Apr 2007 12:27:33 -0000 1.516 +++ squid/src/structs.h 28 Jun 2007 23:22:01 -0000 1.517 @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.516 2007/04/25 12:27:33 hno Exp $ + * $Id: structs.h,v 1.517 2007/06/28 23:22:01 hno Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -806,6 +806,7 @@ #endif time_t refresh_stale_window; int umask; + int max_filedescriptors; }; struct _SquidConfig2 { Index: squid/src/tools.c =================================================================== RCS file: /cvsroot/squid/squid/src/tools.c,v retrieving revision 1.253 retrieving revision 1.254 diff -u -r1.253 -r1.254 --- squid/src/tools.c 21 May 2007 05:53:43 -0000 1.253 +++ squid/src/tools.c 28 Jun 2007 23:22:01 -0000 1.254 @@ -1,6 +1,6 @@ /* - * $Id: tools.c,v 1.253 2007/05/21 05:53:43 adrian Exp $ + * $Id: tools.c,v 1.254 2007/06/28 23:22:01 hno Exp $ * * DEBUG: section 21 Misc Functions * AUTHOR: Harvest Derived @@ -761,6 +761,11 @@ struct rlimit rl; #if !defined(_SQUID_CYGWIN_) #if defined(RLIMIT_NOFILE) + if (Config.max_filedescriptors > 0) { + Squid_MaxFD = rl.rlim_cur = rl.rlim_max = Config.max_filedescriptors; + if (setrlimit(RLIMIT_NOFILE, &rl)) + debug(50, 0) ("setrlimit: RLIMIT_NOFILE: %s\n", xstrerror()); + } if (getrlimit(RLIMIT_NOFILE, &rl) < 0) { debug(50, 0) ("setrlimit: RLIMIT_NOFILE: %s\n", xstrerror()); } else {