SOURCES: squid-fd-config.patch - updated
dzeus
dzeus at pld-linux.org
Fri Nov 24 23:11:55 CET 2006
Author: dzeus Date: Fri Nov 24 22:11:55 2006 GMT
Module: SOURCES Tag: HEAD
---- Log message:
- updated
---- Files affected:
SOURCES:
squid-fd-config.patch (1.1 -> 1.2)
---- Diffs:
================================================================
Index: SOURCES/squid-fd-config.patch
diff -u SOURCES/squid-fd-config.patch:1.1 SOURCES/squid-fd-config.patch:1.2
--- SOURCES/squid-fd-config.patch:1.1 Sun Mar 5 02:11:18 2006
+++ SOURCES/squid-fd-config.patch Fri Nov 24 23:11:49 2006
@@ -1,15 +1,64 @@
---- squid-2.5.STABLE12/configure.in.fdc 2005-10-22 11:56:01.000000000 +0200
-+++ squid-2.5.STABLE12/configure.in 2005-12-06 14:07:43.000000000 +0100
-@@ -445,6 +445,16 @@
+--- squid-2.6.STABLE1/configure.fd 2006-07-26 09:58:41.000000000 +0200
++++ squid-2.6.STABLE1/configure 2006-07-26 09:58:41.000000000 +0200
+@@ -2970,6 +2970,34 @@
+ AMDEP_FALSE=
+ fi
+
++if false; then
++ USE_FD_CONFIG_TRUE=
++ USE_FD_CONFIG_FALSE='#'
++else
++ USE_FD_CONFIG_TRUE='#'
++ USE_FD_CONFIG_FALSE=
++fi
++# Check whether --enable-fd-config or --disable-fd-config was given.
++if test "${enable_fd_config+set}" = set; then
++ enableval="$enable_fd_config"
++ if test "$enableval" = "yes" ; then
++ echo "File descriptor config enabled"
++ cat >> confdefs.h <<\EOF
++#define FD_CONFIG 1
++EOF
++
++
++
++if true; then
++ USE_FD_CONFIG_TRUE=
++ USE_FD_CONFIG_FALSE='#'
++else
++ USE_FD_CONFIG_TRUE='#'
++ USE_FD_CONFIG_FALSE=
++fi
++ fi
++
++fi
+
+
+
+--- squid-2.6.STABLE1/include/autoconf.h.in.fd 2006-07-26 09:58:41.000000000 +0200
++++ squid-2.6.STABLE1/include/autoconf.h.in 2006-07-26 09:58:41.000000000 +0200
+@@ -36,6 +36,9 @@
+ /* Traffic management via "delay pools". */
+ #undef DELAY_POOLS
+
++/* Filedesc managment */
++#undef FD_CONFIG
++
+ /* Enable following X-Forwarded-For headers */
+ #undef FOLLOW_X_FORWARDED_FOR
+
+--- squid-2.6.STABLE1/configure.in.fd 2006-07-26 09:58:41.000000000 +0200
++++ squid-2.6.STABLE1/configure.in 2006-07-26 09:58:41.000000000 +0200
+@@ -501,6 +501,16 @@
fi
])
+AM_CONDITIONAL(USE_FD_CONFIG, false)
+AC_ARG_ENABLE(fd-config,
-+[ --enable-fd-config Enable filedesc config to limit bandwidth usage],
++[ --enable-fd-config Enable filedesc config to configure maximal number of used filedescriptors],
+[ if test "$enableval" = "yes" ; then
+ echo "Filedesc config enabled"
-+ AC_DEFINE(FD_CONFIG)
++ AC_DEFINE(FD_CONFIG, 1, [Maximum number of open file descriptors])
+ AM_CONDITIONAL(USE_FD_CONFIG, true)
+ fi
+])
@@ -17,673 +66,44 @@
dnl This is a developer only option. Developers know how to set defines
dnl
dnl AC_ARG_ENABLE(mem-gen-trace,
---- squid-2.5.STABLE12/include/autoconf.h.in.fdc 2005-09-13 02:12:34.000000000 +0200
-+++ squid-2.5.STABLE12/include/autoconf.h.in 2005-12-06 14:07:43.000000000 +0100
-@@ -125,6 +125,11 @@
- #undef DELAY_POOLS
-
- /*
-+ * Filedesc managment
-+ */
-+#undef FD_CONFIG
-+
-+/*
- * If you want to log User-Agent request header values, define this.
- * By default, they are written to useragent.log in the Squid log
- * directory.
---- squid-2.5.STABLE12/acconfig.h~ 2004-06-01 10:34:19.000000000 +0200
-+++ squid-2.5.STABLE12/acconfig.h 2006-03-05 02:00:21.000000000 +0100
-@@ -88,6 +88,11 @@
- #undef DELAY_POOLS
-
- /*
-+ * Filedesc managment
-+ */
-+#undef FD_CONFIG
-+
-+/*
- * If you want to log User-Agent request header values, define this.
- * By default, they are written to useragent.log in the Squid log
- * directory.
---- squid-2.5.STABLE12/src/cf.data.pre.fdc 2005-12-06 14:07:43.000000000 +0100
-+++ squid-2.5.STABLE12/src/cf.data.pre 2005-12-06 14:07:43.000000000 +0100
-@@ -4161,4 +4161,13 @@
- If set to "off" then such HTTP errors will cause the request
+--- squid-2.6.STABLE1/src/cf.data.pre.fd 2006-07-26 09:58:41.000000000 +0200
++++ squid-2.6.STABLE1/src/cf.data.pre 2006-07-26 10:05:54.000000000 +0200
+@@ -5027,4 +5027,23 @@
or response to be rejected.
DOC_END
-+
+
+NAME: max_filedesc
+IFDEF: FD_CONFIG
+TYPE: int
+DEFAULT: 8192
+LOC: Config.max_filedesc
+DOC_START
-+ The maximum number of open file descriptors.
++ The maximum number of open file descriptors.
++
++ WARNING: Changes of this value isn't respected by reconfigure
++ command. This value should be changed only if there isn't
++ any active squid process.
++
++ NOTE: This option is only supported by system with poll()
++ or epoll(). You can set this value by --with-maxfd during
++ compilation on system whith uses select().
++
++ The maximum value for max_filedesc is set by --with-maxfd during
++ compilation.
+DOC_END
EOF
---- squid-2.5.STABLE12/src/tools.c.fdc 2005-12-06 14:07:43.000000000 +0100
-+++ squid-2.5.STABLE12/src/tools.c 2005-12-06 14:09:02.000000000 +0100
-@@ -685,9 +685,11 @@
- if (getrlimit(RLIMIT_NOFILE, &rl) < 0) {
- debug(50, 0) ("setrlimit: RLIMIT_NOFILE: %s\n", xstrerror());
- } else {
-- rl.rlim_cur = Squid_MaxFD;
-+ rl.rlim_max = rl.rlim_cur = SQUID_NUMFD;
-+/*
- if (rl.rlim_cur > rl.rlim_max)
-- Squid_MaxFD = rl.rlim_cur = rl.rlim_max;
-+ rl.rlim_cur = rl.rlim_max;
-+*/
- if (setrlimit(RLIMIT_NOFILE, &rl) < 0) {
- snprintf(tmp_error_buf, ERROR_BUF_SZ,
- "setrlimit: RLIMIT_NOFILE: %s", xstrerror());
-@@ -698,9 +700,11 @@
- if (getrlimit(RLIMIT_OFILE, &rl) < 0) {
- debug(50, 0) ("setrlimit: RLIMIT_NOFILE: %s\n", xstrerror());
- } else {
-- rl.rlim_cur = Squid_MaxFD;
-+ rl.rlim_max = rl.rlim_cur = SQUID_NUMFD;
-+/*
- if (rl.rlim_cur > rl.rlim_max)
-- Squid_MaxFD = rl.rlim_cur = rl.rlim_max;
-+ rl.rlim_cur = rl.rlim_max;
-+*/
- if (setrlimit(RLIMIT_OFILE, &rl) < 0) {
- snprintf(tmp_error_buf, ERROR_BUF_SZ,
- "setrlimit: RLIMIT_OFILE: %s", xstrerror());
---- squid-2.5.STABLE12/src/structs.h.fdc 2005-09-03 11:14:43.000000000 +0200
-+++ squid-2.5.STABLE12/src/structs.h 2005-12-06 14:07:43.000000000 +0100
-@@ -714,6 +714,9 @@
- char *store_dir_select_algorithm;
- int sleep_after_fork; /* microseconds */
- external_acl *externalAclHelperList;
-+#if FD_CONFIG
-+ int max_filedesc;
-+#endif
- };
-
- struct _SquidConfig2 {
---- /dev/null 2005-12-06 14:01:02.632036776 +0100
-+++ squid-2.5.STABLE12/src/bit_array.h 2005-12-06 14:07:43.000000000 +0100
-@@ -0,0 +1,58 @@
-+/* */
-+
-+#ifndef __BIT_ARRAY_H__
-+#define __BIT_ARRAY_H__
-+
-+#if !BIT_ARRAY_ACTIVE
-+
-+#define BIT_ARRAY fd_set
-+#define BA_INIT(arr,len)
-+#define BA_FREE(arr)
-+
-+#define BA_ZERO(arr) FD_ZERO(&arr)
-+#define BA_SET(fd,arr) FD_SET(fd,&arr)
-+#define BA_CLR(fd,arr) FD_CLR(fd,&arr)
-+#define BA_ISSET(fd,arr) FD_ISSET(fd,&arr)
-+
-+#else
-+
-+typedef struct _BIT_ARRAY {
-+
-+ int *p_pool;
-+ int len;
-+ int offset_mask;
-+ int base_shift;
-+
-+} BIT_ARRAY;
-+
-+#define BA_INIT(arr,lenght) \
-+{ \
-+ int i,tmp = sizeof((arr).p_pool[0])*8; \
-+ \
-+ for(i = 2, (arr).base_shift = 1; i < tmp; i *= 2) \
-+ (arr).base_shift++; \
-+ (arr).offset_mask = (i-1); \
-+ \
-+ (arr).len = lenght / (sizeof((arr).p_pool[0])*8) + 1; \
-+ (arr).p_pool = xmalloc(sizeof((arr).p_pool[0])*(arr).len); \
-+} \
-+
-+
-+#define BA_FREE(arr) \
-+{ \
-+ if((arr).p_pool) { \
-+ xfree((arr).p_pool); \
-+ (arr).p_pool = NULL; \
-+ } \
-+ (arr).len = 0; \
-+} \
-+
-+
-+#define BA_ZERO(arr) { memset((arr).p_pool, 0, sizeof((arr).p_pool[0])*(arr).len); }
-+#define BA_SET(fdsp, arr) { (arr).p_pool[(fdsp)>>(arr).base_shift]|=(0x1<<((fdsp)&(arr).offset_mask)); }
-+#define BA_CLR(fdsp, arr) { (arr).p_pool[(fdsp)>>(arr).base_shift]&=(~(0x1<<((fdsp)&(arr).offset_mask))); }
-+#define BA_ISSET(fdsp, arr) ((arr).p_pool[(fdsp)>>(arr).base_shift]&(0x1<<((fdsp)&(arr).offset_mask)))
-+
-+#endif // BIT_ARRAY_ACTIVE
-+
-+#endif //__BIT_ARRAY_H__
---- squid-2.5.STABLE12/src/fd.c.fdc 2003-12-14 13:30:36.000000000 +0100
-+++ squid-2.5.STABLE12/src/fd.c 2005-12-06 14:07:43.000000000 +0100
-@@ -55,7 +55,7 @@
- {
- if (fd < Biggest_FD)
- return;
-- assert(fd < Squid_MaxFD);
-+ assert(fd < SQUID_NUMFD);
- if (fd > Biggest_FD) {
- /*
- * assert that we are not closing a FD bigger than
-@@ -158,7 +158,7 @@
- {
- int i;
- fde *F;
-- for (i = 0; i < Squid_MaxFD; i++) {
-+ for (i = 0; i < SQUID_NUMFD; i++) {
- F = &fd_table[i];
- if (!F->flags.open)
- continue;
-@@ -175,7 +175,7 @@
- int
- fdNFree(void)
- {
-- return Squid_MaxFD - Number_FD - Opening_FD;
-+ return SQUID_NUMFD - Number_FD - Opening_FD;
- }
-
- int
-@@ -204,10 +204,10 @@
- /*
- * Calculate a new reserve, based on current usage and a small extra
- */
-- new = Squid_MaxFD - Number_FD + XMIN(25, Squid_MaxFD / 16);
-+ new = SQUID_NUMFD - Number_FD + XMIN(25, SQUID_NUMFD / 16);
- if (new <= RESERVED_FD)
- return;
-- x = Squid_MaxFD - 20 - XMIN(25, Squid_MaxFD / 16);
-+ x = SQUID_NUMFD - 20 - XMIN(25, SQUID_NUMFD / 16);
- if (new > x) {
- /* perhaps this should be fatal()? -DW */
- debug(51, 0) ("WARNING: This machine has a serious shortage of filedescriptors.\n");
---- squid-2.5.STABLE12/src/mem.c.fdc 2001-09-07 20:02:45.000000000 +0200
-+++ squid-2.5.STABLE12/src/mem.c 2005-12-06 14:07:43.000000000 +0100
-@@ -224,13 +224,13 @@
- memDataInit(MEM_HTTP_HDR_CONTENT_RANGE, "HttpHdrContRange", sizeof(HttpHdrContRange), 0);
- memDataInit(MEM_INTLIST, "intlist", sizeof(intlist), 0);
- memDataInit(MEM_MEMOBJECT, "MemObject", sizeof(MemObject),
-- Squid_MaxFD >> 3);
-+ SQUID_NUMFD >> 3);
- memDataInit(MEM_MEM_NODE, "mem_node", sizeof(mem_node), 0);
- memDataInit(MEM_NETDBENTRY, "netdbEntry", sizeof(netdbEntry), 0);
- memDataInit(MEM_NET_DB_NAME, "net_db_name", sizeof(net_db_name), 0);
- memDataInit(MEM_RELIST, "relist", sizeof(relist), 0);
- memDataInit(MEM_REQUEST_T, "request_t", sizeof(request_t),
-- Squid_MaxFD >> 3);
-+ SQUID_NUMFD >> 3);
- memDataInit(MEM_STOREENTRY, "StoreEntry", sizeof(StoreEntry), 0);
- memDataInit(MEM_WORDLIST, "wordlist", sizeof(wordlist), 0);
- memDataInit(MEM_CLIENT_INFO, "ClientInfo", sizeof(ClientInfo), 0);
---- squid-2.5.STABLE12/src/comm_select.c.fdc 2003-05-11 19:30:13.000000000 +0200
-+++ squid-2.5.STABLE12/src/comm_select.c 2005-12-06 14:07:43.000000000 +0100
-@@ -66,10 +66,10 @@
- #if !HAVE_POLL
- static struct timeval zero_tv;
- #endif
--static fd_set global_readfds;
--static fd_set global_writefds;
- static int nreadfds;
- static int nwritefds;
-+static BIT_ARRAY global_readfds;
-+static BIT_ARRAY global_writefds;
-
- /*
- * Automatic tuning for incoming requests:
-@@ -171,13 +171,39 @@
- }
-
- #if DELAY_POOLS
-+
-+#if FD_CONFIG
-+static int *slowfdarr = NULL;
-+static int slowfdmax;
-+#else
-+static int slowfdarr[SQUID_NUMFD];
-+static int slowfdmax = SQUID_NUMFD;
-+#endif
-+
- static int slowfdcnt = 0;
--static int slowfdarr[SQUID_MAXFD];
-+
-+#if FD_CONFIG
-+void
-+comm_slow_fd_init(int fd_num)
-+{
-+ slowfdarr = xmalloc(sizeof(slowfdarr[0])*fd_num);
-+ slowfdmax = fd_num;
-+ slowfdcnt = 0;
-+}
-+
-+void
-+comm_slow_fd_destroy(void)
-+{
-+ xfree(slowfdarr);
-+ slowfdarr = NULL;
-+ slowfdmax = slowfdcnt = 0;
-+}
-+#endif
-
- static void
- commAddSlowFd(int fd)
- {
-- assert(slowfdcnt < SQUID_MAXFD);
-+ assert(slowfdcnt < slowfdmax);
- slowfdarr[slowfdcnt++] = fd;
- }
-
-@@ -308,9 +334,13 @@
- int
- comm_poll(int msec)
- {
-- struct pollfd pfds[SQUID_MAXFD];
-+#if FD_CONFIG
-+ struct pollfd *pfds = NULL;
-+#else
-+ struct pollfd pfds[SQUID_NUMFD];
-+#endif
- #if DELAY_POOLS
-- fd_set slowfds;
-+ BIT_ARRAY slowfds;
- #endif
- PF *hdl = NULL;
- int fd;
-@@ -323,6 +353,12 @@
- int calldns = 0;
- static time_t last_timeout = 0;
- double timeout = current_dtime + (msec / 1000.0);
-+#if FD_CONFIG
-+ pfds = xmalloc(sizeof(pfds[0])*SQUID_NUMFD);
-+#endif
-+#if DELAY_POOLS
-+ BA_INIT(slowfds,SQUID_NUMFD);
-+#endif
- do {
- #if !ALARM_UPDATES_TIME
- double start;
-@@ -332,7 +368,7 @@
- /* Handle any fs callbacks that need doing */
- storeDirCallback();
- #if DELAY_POOLS
-- FD_ZERO(&slowfds);
-+ BA_ZERO(slowfds);
- #endif
- if (commCheckICPIncoming)
- comm_poll_icp_incoming();
-@@ -358,7 +394,7 @@
- #if DELAY_POOLS
- case -1:
- events |= POLLRDNORM;
-- FD_SET(i, &slowfds);
-+ BA_SET(i, slowfds);
- break;
- #endif
- default:
-@@ -378,6 +414,12 @@
- }
- if (nfds == 0) {
- assert(shutting_down);
-+#if DELAY_POOLS
-+ BA_FREE(slowfds);
-+#endif
-+#if FD_CONFIG
-+ xfree(pfds);
-+#endif
- return COMM_SHUTDOWN;
- }
- if (npending)
-@@ -394,6 +436,12 @@
- continue;
- debug(5, 0) ("comm_poll: poll failure: %s\n", xstrerror());
- assert(errno != EINVAL);
-+#if DELAY_POOLS
-+ BA_FREE(slowfds);
-+#endif
-+#if FD_CONFIG
-+ xfree(pfds);
-+#endif
- return COMM_ERROR;
- /* NOTREACHED */
- }
-@@ -437,7 +485,7 @@
- if (NULL == (hdl = F->read_handler))
- (void) 0;
- #if DELAY_POOLS
-- else if (FD_ISSET(fd, &slowfds))
-+ else if (BA_ISSET(fd, slowfds))
- commAddSlowFd(fd);
- #endif
- else {
-@@ -518,10 +566,22 @@
- getCurrentTime();
- statCounter.select_time += (current_dtime - start);
- #endif
-+#if DELAY_POOLS
-+ BA_FREE(slowfds);
-+#endif
-+#if FD_CONFIG
-+ xfree(pfds);
-+#endif
- return COMM_OK;
- }
- while (timeout > current_dtime);
- debug(5, 8) ("comm_poll: time out: %ld.\n", (long int) squid_curtime);
-+#if DELAY_POOLS
-+ BA_FREE(slowfds);
-+#endif
-+#if FD_CONFIG
-+ xfree(pfds);
-+#endif
- return COMM_TIMEOUT;
- }
-
-@@ -646,7 +706,7 @@
- fd_set pendingfds;
- fd_set writefds;
- #if DELAY_POOLS
-- fd_set slowfds;
-+ BIT_ARRAY slowfds;
- #endif
- PF *hdl = NULL;
- int fd;
-@@ -668,6 +728,9 @@
- struct timeval poll_time;
- double timeout = current_dtime + (msec / 1000.0);
- fde *F;
-+#if DELAY_POOLS
-+ BA_INIT(slowfds,SQUID_NUMFD);
-+#endif
- do {
- #if !ALARM_UPDATES_TIME
- double start;
-@@ -675,7 +738,7 @@
- start = current_dtime;
- #endif
- #if DELAY_POOLS
-- FD_ZERO(&slowfds);
-+ BA_ZERO(slowfds);
- #endif
- /* Handle any fs callbacks that need doing */
- storeDirCallback();
-@@ -712,7 +771,7 @@
- break;
- #if DELAY_POOLS
- case -1:
-- FD_SET(fd, &slowfds);
-+ BA_SET(fd, slowfds);
- break;
- #endif
- default:
-@@ -741,6 +800,9 @@
- #endif
- if (nreadfds + nwritefds == 0) {
- assert(shutting_down);
-+#if DELAY_POOLS
-+ BA_FREE(slowfds);
-+#endif
- return COMM_SHUTDOWN;
- }
- if (msec > MAX_POLL_TIME)
-@@ -760,6 +822,9 @@
- debug(50, 0) ("comm_select: select failure: %s\n",
- xstrerror());
- examine_select(&readfds, &writefds);
-+#if DELAY_POOLS
-+ BA_FREE(slowfds);
-+#endif
- return COMM_ERROR;
- /* NOTREACHED */
- }
-@@ -812,7 +877,7 @@
- if (NULL == (hdl = F->read_handler))
- (void) 0;
- #if DELAY_POOLS
-- else if (FD_ISSET(fd, &slowfds))
-+ else if (BA_ISSET(fd, slowfds))
- commAddSlowFd(fd);
- #endif
- else {
-@@ -901,10 +966,16 @@
- getCurrentTime();
- statCounter.select_time += (current_dtime - start);
- #endif
-+#if DELAY_POOLS
-+ BA_FREE(slowfds);
-+#endif
- return COMM_OK;
- }
- while (timeout > current_dtime);
- debug(5, 8) ("comm_select: time out: %d\n", (int) squid_curtime);
-+#if DELAY_POOLS
-+ BA_FREE(slowfds);
-+#endif
- return COMM_TIMEOUT;
- }
- #endif
-@@ -950,8 +1021,12 @@
- cachemgrRegister("comm_incoming",
- "comm_incoming() stats",
- commIncomingStats, 0, 1);
-- FD_ZERO(&global_readfds);
-- FD_ZERO(&global_writefds);
-+
-+ BA_INIT(global_readfds,SQUID_NUMFD);
-+ BA_INIT(global_writefds,SQUID_NUMFD);
-+
-+ BA_ZERO(global_readfds);
-+ BA_ZERO(global_writefds);
- nreadfds = nwritefds = 0;
- }
-
-@@ -977,7 +1052,7 @@
- fde *F = NULL;
- struct stat sb;
- debug(5, 0) ("examine_select: Examining open file descriptors...\n");
-- for (fd = 0; fd < Squid_MaxFD; fd++) {
-+ for (fd = 0; fd < SQUID_NUMFD; fd++) {
- FD_ZERO(&read_x);
- FD_ZERO(&write_x);
- tv.tv_sec = tv.tv_usec = 0;
-@@ -1085,11 +1160,11 @@
- void
- commUpdateReadBits(int fd, PF * handler)
- {
-- if (handler && !FD_ISSET(fd, &global_readfds)) {
-- FD_SET(fd, &global_readfds);
-+ if (handler && !BA_ISSET(fd, global_readfds)) {
-+ BA_SET(fd, global_readfds);
- nreadfds++;
-- } else if (!handler && FD_ISSET(fd, &global_readfds)) {
-- FD_CLR(fd, &global_readfds);
-+ } else if (!handler && BA_ISSET(fd, global_readfds)) {
-+ BA_CLR(fd, global_readfds);
- nreadfds--;
- }
- }
-@@ -1097,11 +1172,11 @@
- void
- commUpdateWriteBits(int fd, PF * handler)
- {
-- if (handler && !FD_ISSET(fd, &global_writefds)) {
-- FD_SET(fd, &global_writefds);
-+ if (handler && !BA_ISSET(fd, global_writefds)) {
-+ BA_SET(fd, global_writefds);
- nwritefds++;
-- } else if (!handler && FD_ISSET(fd, &global_writefds)) {
<<Diff was trimmed, longer than 597 lines>>
---- CVS-web:
http://cvs.pld-linux.org/SOURCES/squid-fd-config.patch?r1=1.1&r2=1.2&f=u
More information about the pld-cvs-commit
mailing list