--- 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 @@ fi ]) +AM_CONDITIONAL(USE_FD_CONFIG, false) +AC_ARG_ENABLE(fd-config, +[ --enable-fd-config Enable filedesc config to limit bandwidth usage], +[ if test "$enableval" = "yes" ; then + echo "Filedesc config enabled" + AC_DEFINE(FD_CONFIG) + AM_CONDITIONAL(USE_FD_CONFIG, true) + fi +]) + 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 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. +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)) { - FD_CLR(fd, &global_writefds); + } else if (!handler && BA_ISSET(fd, global_writefds)) { + BA_CLR(fd, global_writefds); nwritefds--; } } --- squid-2.5.STABLE12/src/globals.h.fdc 2005-06-14 00:26:21.000000000 +0200 +++ squid-2.5.STABLE12/src/globals.h 2005-12-06 14:07:43.000000000 +0100 @@ -72,7 +72,6 @@ extern int NDnsServersAlloc; /* 0 */ extern int NHttpSockets; /* 0 */ extern int RESERVED_FD; -extern int Squid_MaxFD; /* SQUID_MAXFD */ extern int config_lineno; /* 0 */ extern int debugLevels[MAX_DEBUG_SECTIONS]; extern int do_mallinfo; /* 0 */ --- squid-2.5.STABLE12/src/ident.c.fdc 2001-04-14 02:03:23.000000000 +0200 +++ squid-2.5.STABLE12/src/ident.c 2005-12-06 14:07:43.000000000 +0100 @@ -238,7 +238,7 @@ identInit(void) { ident_hash = hash_create((HASHCMP *) strcmp, - hashPrime(Squid_MaxFD / 8), + hashPrime(SQUID_NUMFD / 8), hash4); } --- squid-2.5.STABLE12/src/snmp_agent.c.fdc 2004-06-01 00:39:00.000000000 +0200 +++ squid-2.5.STABLE12/src/snmp_agent.c 2005-12-06 14:07:43.000000000 +0100 @@ -289,7 +289,7 @@ break; case PERF_SYS_CURUNUSED_FD: Answer = snmp_var_new_integer(Var->name, Var->name_length, - (snint) Squid_MaxFD - Number_FD, + (snint) SQUID_NUMFD - Number_FD, SMI_GAUGE32); break; case PERF_SYS_CURRESERVED_FD: --- squid-2.5.STABLE12/src/comm.c.fdc 2005-09-10 12:17:55.000000000 +0200 +++ squid-2.5.STABLE12/src/comm.c 2005-12-06 14:07:43.000000000 +0100 @@ -239,7 +239,7 @@ } /* - * NOTE: set the listen queue to Squid_MaxFD/4 and rely on the kernel to + * NOTE: set the listen queue to Squid_MAXFD/4 and rely on the kernel to * impose an upper limit. Solaris' listen(3n) page says it has * no limit on this parameter, but sys/socket.h sets SOMAXCONN * to 5. HP-UX currently has a limit of 20. SunOS is 5 and @@ -249,9 +249,9 @@ comm_listen(int sock) { int x; - if ((x = listen(sock, Squid_MaxFD >> 2)) < 0) { + if ((x = listen(sock, SQUID_NUMFD >> 2)) < 0) { debug(50, 0) ("comm_listen: listen(%d, %d): %s\n", - Squid_MaxFD >> 2, + SQUID_NUMFD >> 2, sock, xstrerror()); return x; } @@ -441,7 +441,7 @@ fde *F; debug(5, 3) ("commSetTimeout: FD %d timeout %d\n", fd, timeout); assert(fd >= 0); - assert(fd < Squid_MaxFD); + assert(fd < SQUID_NUMFD); F = &fd_table[fd]; assert(F->flags.open); if (timeout < 0) { @@ -637,7 +637,7 @@ debug(5, 5) ("comm_close: FD %d\n", fd); assert(fd >= 0); - assert(fd < Squid_MaxFD); + assert(fd < SQUID_NUMFD); F = &fd_table[fd]; if (F->flags.closing) @@ -862,12 +862,12 @@ void comm_init(void) { - fd_table = xcalloc(Squid_MaxFD, sizeof(fde)); + fd_table = xcalloc(SQUID_NUMFD, sizeof(fde)); /* XXX account fd_table */ /* Keep a few file descriptors free so that we don't run out of FD's * after accepting a client but before it opens a socket or a file. * Since Squid_MaxFD can be as high as several thousand, don't waste them */ - RESERVED_FD = XMIN(100, Squid_MaxFD / 4); + RESERVED_FD = XMIN(100, SQUID_NUMFD / 4); CBDATA_INIT_TYPE(ConnectStateData); comm_write_pool = memPoolCreate("CommWriteStateData", sizeof(CommWriteStateData)); conn_close_pool = memPoolCreate("close_handler", sizeof(close_handler)); --- squid-2.5.STABLE12/src/ipc.c.fdc 2001-10-17 22:25:02.000000000 +0200 +++ squid-2.5.STABLE12/src/ipc.c 2005-12-06 14:07:43.000000000 +0100 @@ -276,7 +276,7 @@ close(t2); close(t3); /* Make sure all other filedescriptors are closed */ - for (x = 3; x < SQUID_MAXFD; x++) + for (x = 3; x < SQUID_NUMFD; x++) close(x); #if HAVE_SETSID setsid(); --- squid-2.5.STABLE12/src/main.c.fdc 2005-06-27 23:24:28.000000000 +0200 +++ squid-2.5.STABLE12/src/main.c 2005-12-06 14:09:21.000000000 +0100 @@ -350,6 +350,9 @@ #else idnsShutdown(); #endif +#if FD_CONFIG + comm_slow_fd_destroy(); +#endif redirectShutdown(); authenticateShutdown(); externalAclShutdown(); @@ -383,6 +386,9 @@ #if USE_WCCP wccpInit(); #endif +#if FD_CONFIG + comm_slow_fd_init(SQUID_NUMFD); +#endif serverConnectionsOpen(); if (theOutIcpConnection >= 0) { if (!Config2.Accel.on || Config.onoff.accel_with_proxy) @@ -494,7 +500,7 @@ version_string, CONFIG_HOST_TYPE); debug(1, 1) ("Process ID %d\n", (int) getpid()); - debug(1, 1) ("With %d file descriptors available\n", Squid_MaxFD); + debug(1, 1) ("With %d file descriptors available\n", SQUID_NUMFD); if (!configured_once) disk_init(); /* disk_init must go before ipcache_init() */ @@ -506,6 +512,9 @@ #else idnsInit(); #endif +#if FD_CONFIG + comm_slow_fd_init(SQUID_NUMFD); +#endif redirectInit(); authenticateInit(&Config.authConfig); externalAclInit(); @@ -600,8 +609,6 @@ #endif debug_log = stderr; - if (FD_SETSIZE < Squid_MaxFD) - Squid_MaxFD = FD_SETSIZE; #if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_) if ((WIN32_init_err = WIN32_Subsystem_Init())) @@ -680,6 +687,8 @@ return 0; #endif + setMaxFD(); + /* send signal to running copy and exit */ if (opt_send_signal != -1) { /* chroot if configured to run inside chroot */ @@ -705,7 +714,6 @@ } if (!opt_no_daemon) watch_child(argv); - setMaxFD(); /* init comm module */ comm_init(); @@ -977,6 +985,9 @@ #endif releaseServerSockets(); commCloseAllSockets(); +#if FD_CONFIG + comm_slow_fd_destroy(); +#endif authenticateShutdown(); #if USE_UNLINKD unlinkdClose(); --- squid-2.5.STABLE12/src/stat.c.fdc 2005-03-29 11:52:00.000000000 +0200 +++ squid-2.5.STABLE12/src/stat.c 2005-12-06 14:07:43.000000000 +0100 @@ -451,7 +451,7 @@ "Remote Address", "Description"); storeAppendPrintf(sentry, "---- ------ ---- -------- -------- --------------------- ------------------------------\n"); - for (i = 0; i < Squid_MaxFD; i++) { + for (i = 0; i < SQUID_NUMFD; i++) { f = &fd_table[i]; if (!f->flags.open) continue; @@ -634,7 +634,7 @@ storeAppendPrintf(sentry, "File descriptor usage for %s:\n", appname); storeAppendPrintf(sentry, "\tMaximum number of file descriptors: %4d\n", - Squid_MaxFD); + SQUID_NUMFD); storeAppendPrintf(sentry, "\tLargest file desc currently in use: %4d\n", Biggest_FD); storeAppendPrintf(sentry, "\tNumber of file desc currently in use: %4d\n", @@ -1026,7 +1026,7 @@ statHistEnumInit(&C->comm_icp_incoming, INCOMING_ICP_MAX); statHistEnumInit(&C->comm_dns_incoming, INCOMING_DNS_MAX); statHistEnumInit(&C->comm_http_incoming, INCOMING_HTTP_MAX); - statHistIntInit(&C->select_fds_hist, 256); /* was SQUID_MAXFD, but it is way too much. It is OK to crop this statistics */ + statHistIntInit(&C->select_fds_hist, 256); /* was SQUID_NUMFD, but it is way too much. It is OK to crop this statistics */ } /* add special cases here as they arrive */ --- squid-2.5.STABLE12/src/delay_pools.c.fdc 2005-10-20 19:30:31.000000000 +0200 +++ squid-2.5.STABLE12/src/delay_pools.c 2005-12-06 14:07:43.000000000 +0100 @@ -89,7 +89,7 @@ typedef union _delayPool delayPool; static delayPool *delay_data = NULL; -static fd_set delay_no_delay; +static BIT_ARRAY delay_no_delay; static time_t delay_pools_last_update = 0; static hash_table *delay_id_ptr_hash = NULL; static long memory_used = 0; @@ -134,7 +134,8 @@ delayPoolsInit(void) { delay_pools_last_update = getCurrentTime(); - FD_ZERO(&delay_no_delay); + BA_INIT(delay_no_delay,SQUID_NUMFD); + BA_ZERO(delay_no_delay); cachemgrRegister("delay", "Delay Pool Levels", delayPoolStats, 0, 1); } @@ -169,6 +170,7 @@ hashFreeItems(delay_id_ptr_hash, delayIdZero); hashFreeMemory(delay_id_ptr_hash); delay_id_ptr_hash = NULL; + BA_FREE(delay_no_delay); } void @@ -283,19 +285,19 @@ void delaySetNoDelay(int fd) { - FD_SET(fd, &delay_no_delay); + BA_SET(fd, delay_no_delay); } void delayClearNoDelay(int fd) { - FD_CLR(fd, &delay_no_delay); + BA_CLR(fd, delay_no_delay); } int delayIsNoDelay(int fd) { - return FD_ISSET(fd, &delay_no_delay); + return BA_ISSET(fd, delay_no_delay); } static delay_id --- squid-2.5.STABLE12/src/squid.h.fdc 2005-03-26 03:50:53.000000000 +0100 +++ squid-2.5.STABLE12/src/squid.h 2005-12-06 14:07:43.000000000 +0100 @@ -400,6 +400,20 @@ #include "cache_snmp.h" #endif +#if !HAVE_POLL +#define FD_CONFIG 0 +#endif + +#if FD_CONFIG +#define SQUID_NUMFD (Config.max_filedesc) +#define BIT_ARRAY_ACTIVE 1 +#else +#define SQUID_NUMFD SQUID_MAXFD +#define BIT_ARRAY_ACTIVE 0 +#endif + +#include "bit_array.h" + #include "hash.h" #include "rfc1035.h"