]> git.pld-linux.org Git - packages/squid.git/blame - squid-fd-config.patch
- fix for assertion failed: HttpReply.c:105: "rep"
[packages/squid.git] / squid-fd-config.patch
CommitLineData
0dee7b7b
JR
1--- squid-2.5.STABLE12/configure.in.fdc 2005-10-22 11:56:01.000000000 +0200
2+++ squid-2.5.STABLE12/configure.in 2005-12-06 14:07:43.000000000 +0100
3@@ -445,6 +445,16 @@
4 fi
5 ])
6
7+AM_CONDITIONAL(USE_FD_CONFIG, false)
8+AC_ARG_ENABLE(fd-config,
9+[ --enable-fd-config Enable filedesc config to limit bandwidth usage],
10+[ if test "$enableval" = "yes" ; then
11+ echo "Filedesc config enabled"
12+ AC_DEFINE(FD_CONFIG)
13+ AM_CONDITIONAL(USE_FD_CONFIG, true)
14+ fi
15+])
16+
17 dnl This is a developer only option. Developers know how to set defines
18 dnl
19 dnl AC_ARG_ENABLE(mem-gen-trace,
20--- squid-2.5.STABLE12/include/autoconf.h.in.fdc 2005-09-13 02:12:34.000000000 +0200
21+++ squid-2.5.STABLE12/include/autoconf.h.in 2005-12-06 14:07:43.000000000 +0100
22@@ -125,6 +125,11 @@
23 #undef DELAY_POOLS
24
25 /*
26+ * Filedesc managment
27+ */
28+#undef FD_CONFIG
29+
30+/*
31 * If you want to log User-Agent request header values, define this.
32 * By default, they are written to useragent.log in the Squid log
33 * directory.
34--- squid-2.5.STABLE12/acconfig.h~ 2004-06-01 10:34:19.000000000 +0200
35+++ squid-2.5.STABLE12/acconfig.h 2006-03-05 02:00:21.000000000 +0100
36@@ -88,6 +88,11 @@
37 #undef DELAY_POOLS
38
39 /*
40+ * Filedesc managment
41+ */
42+#undef FD_CONFIG
43+
44+/*
45 * If you want to log User-Agent request header values, define this.
46 * By default, they are written to useragent.log in the Squid log
47 * directory.
48--- squid-2.5.STABLE12/src/cf.data.pre.fdc 2005-12-06 14:07:43.000000000 +0100
49+++ squid-2.5.STABLE12/src/cf.data.pre 2005-12-06 14:07:43.000000000 +0100
50@@ -4161,4 +4161,13 @@
51 If set to "off" then such HTTP errors will cause the request
52 or response to be rejected.
53 DOC_END
54+
55+NAME: max_filedesc
56+IFDEF: FD_CONFIG
57+TYPE: int
58+DEFAULT: 8192
59+LOC: Config.max_filedesc
60+DOC_START
61+ The maximum number of open file descriptors.
62+DOC_END
63 EOF
64--- squid-2.5.STABLE12/src/tools.c.fdc 2005-12-06 14:07:43.000000000 +0100
65+++ squid-2.5.STABLE12/src/tools.c 2005-12-06 14:09:02.000000000 +0100
66@@ -685,9 +685,11 @@
67 if (getrlimit(RLIMIT_NOFILE, &rl) < 0) {
68 debug(50, 0) ("setrlimit: RLIMIT_NOFILE: %s\n", xstrerror());
69 } else {
70- rl.rlim_cur = Squid_MaxFD;
71+ rl.rlim_max = rl.rlim_cur = SQUID_NUMFD;
72+/*
73 if (rl.rlim_cur > rl.rlim_max)
74- Squid_MaxFD = rl.rlim_cur = rl.rlim_max;
75+ rl.rlim_cur = rl.rlim_max;
76+*/
77 if (setrlimit(RLIMIT_NOFILE, &rl) < 0) {
78 snprintf(tmp_error_buf, ERROR_BUF_SZ,
79 "setrlimit: RLIMIT_NOFILE: %s", xstrerror());
80@@ -698,9 +700,11 @@
81 if (getrlimit(RLIMIT_OFILE, &rl) < 0) {
82 debug(50, 0) ("setrlimit: RLIMIT_NOFILE: %s\n", xstrerror());
83 } else {
84- rl.rlim_cur = Squid_MaxFD;
85+ rl.rlim_max = rl.rlim_cur = SQUID_NUMFD;
86+/*
87 if (rl.rlim_cur > rl.rlim_max)
88- Squid_MaxFD = rl.rlim_cur = rl.rlim_max;
89+ rl.rlim_cur = rl.rlim_max;
90+*/
91 if (setrlimit(RLIMIT_OFILE, &rl) < 0) {
92 snprintf(tmp_error_buf, ERROR_BUF_SZ,
93 "setrlimit: RLIMIT_OFILE: %s", xstrerror());
94--- squid-2.5.STABLE12/src/structs.h.fdc 2005-09-03 11:14:43.000000000 +0200
95+++ squid-2.5.STABLE12/src/structs.h 2005-12-06 14:07:43.000000000 +0100
96@@ -714,6 +714,9 @@
97 char *store_dir_select_algorithm;
98 int sleep_after_fork; /* microseconds */
99 external_acl *externalAclHelperList;
100+#if FD_CONFIG
101+ int max_filedesc;
102+#endif
103 };
104
105 struct _SquidConfig2 {
106--- /dev/null 2005-12-06 14:01:02.632036776 +0100
107+++ squid-2.5.STABLE12/src/bit_array.h 2005-12-06 14:07:43.000000000 +0100
108@@ -0,0 +1,58 @@
109+/* */
110+
111+#ifndef __BIT_ARRAY_H__
112+#define __BIT_ARRAY_H__
113+
114+#if !BIT_ARRAY_ACTIVE
115+
116+#define BIT_ARRAY fd_set
117+#define BA_INIT(arr,len)
118+#define BA_FREE(arr)
119+
120+#define BA_ZERO(arr) FD_ZERO(&arr)
121+#define BA_SET(fd,arr) FD_SET(fd,&arr)
122+#define BA_CLR(fd,arr) FD_CLR(fd,&arr)
123+#define BA_ISSET(fd,arr) FD_ISSET(fd,&arr)
124+
125+#else
126+
127+typedef struct _BIT_ARRAY {
128+
129+ int *p_pool;
130+ int len;
131+ int offset_mask;
132+ int base_shift;
133+
134+} BIT_ARRAY;
135+
136+#define BA_INIT(arr,lenght) \
137+{ \
138+ int i,tmp = sizeof((arr).p_pool[0])*8; \
139+ \
140+ for(i = 2, (arr).base_shift = 1; i < tmp; i *= 2) \
141+ (arr).base_shift++; \
142+ (arr).offset_mask = (i-1); \
143+ \
144+ (arr).len = lenght / (sizeof((arr).p_pool[0])*8) + 1; \
145+ (arr).p_pool = xmalloc(sizeof((arr).p_pool[0])*(arr).len); \
146+} \
147+
148+
149+#define BA_FREE(arr) \
150+{ \
151+ if((arr).p_pool) { \
152+ xfree((arr).p_pool); \
153+ (arr).p_pool = NULL; \
154+ } \
155+ (arr).len = 0; \
156+} \
157+
158+
159+#define BA_ZERO(arr) { memset((arr).p_pool, 0, sizeof((arr).p_pool[0])*(arr).len); }
160+#define BA_SET(fdsp, arr) { (arr).p_pool[(fdsp)>>(arr).base_shift]|=(0x1<<((fdsp)&(arr).offset_mask)); }
161+#define BA_CLR(fdsp, arr) { (arr).p_pool[(fdsp)>>(arr).base_shift]&=(~(0x1<<((fdsp)&(arr).offset_mask))); }
162+#define BA_ISSET(fdsp, arr) ((arr).p_pool[(fdsp)>>(arr).base_shift]&(0x1<<((fdsp)&(arr).offset_mask)))
163+
164+#endif // BIT_ARRAY_ACTIVE
165+
166+#endif //__BIT_ARRAY_H__
167--- squid-2.5.STABLE12/src/fd.c.fdc 2003-12-14 13:30:36.000000000 +0100
168+++ squid-2.5.STABLE12/src/fd.c 2005-12-06 14:07:43.000000000 +0100
169@@ -55,7 +55,7 @@
170 {
171 if (fd < Biggest_FD)
172 return;
173- assert(fd < Squid_MaxFD);
174+ assert(fd < SQUID_NUMFD);
175 if (fd > Biggest_FD) {
176 /*
177 * assert that we are not closing a FD bigger than
178@@ -158,7 +158,7 @@
179 {
180 int i;
181 fde *F;
182- for (i = 0; i < Squid_MaxFD; i++) {
183+ for (i = 0; i < SQUID_NUMFD; i++) {
184 F = &fd_table[i];
185 if (!F->flags.open)
186 continue;
187@@ -175,7 +175,7 @@
188 int
189 fdNFree(void)
190 {
191- return Squid_MaxFD - Number_FD - Opening_FD;
192+ return SQUID_NUMFD - Number_FD - Opening_FD;
193 }
194
195 int
196@@ -204,10 +204,10 @@
197 /*
198 * Calculate a new reserve, based on current usage and a small extra
199 */
200- new = Squid_MaxFD - Number_FD + XMIN(25, Squid_MaxFD / 16);
201+ new = SQUID_NUMFD - Number_FD + XMIN(25, SQUID_NUMFD / 16);
202 if (new <= RESERVED_FD)
203 return;
204- x = Squid_MaxFD - 20 - XMIN(25, Squid_MaxFD / 16);
205+ x = SQUID_NUMFD - 20 - XMIN(25, SQUID_NUMFD / 16);
206 if (new > x) {
207 /* perhaps this should be fatal()? -DW */
208 debug(51, 0) ("WARNING: This machine has a serious shortage of filedescriptors.\n");
209--- squid-2.5.STABLE12/src/mem.c.fdc 2001-09-07 20:02:45.000000000 +0200
210+++ squid-2.5.STABLE12/src/mem.c 2005-12-06 14:07:43.000000000 +0100
211@@ -224,13 +224,13 @@
212 memDataInit(MEM_HTTP_HDR_CONTENT_RANGE, "HttpHdrContRange", sizeof(HttpHdrContRange), 0);
213 memDataInit(MEM_INTLIST, "intlist", sizeof(intlist), 0);
214 memDataInit(MEM_MEMOBJECT, "MemObject", sizeof(MemObject),
215- Squid_MaxFD >> 3);
216+ SQUID_NUMFD >> 3);
217 memDataInit(MEM_MEM_NODE, "mem_node", sizeof(mem_node), 0);
218 memDataInit(MEM_NETDBENTRY, "netdbEntry", sizeof(netdbEntry), 0);
219 memDataInit(MEM_NET_DB_NAME, "net_db_name", sizeof(net_db_name), 0);
220 memDataInit(MEM_RELIST, "relist", sizeof(relist), 0);
221 memDataInit(MEM_REQUEST_T, "request_t", sizeof(request_t),
222- Squid_MaxFD >> 3);
223+ SQUID_NUMFD >> 3);
224 memDataInit(MEM_STOREENTRY, "StoreEntry", sizeof(StoreEntry), 0);
225 memDataInit(MEM_WORDLIST, "wordlist", sizeof(wordlist), 0);
226 memDataInit(MEM_CLIENT_INFO, "ClientInfo", sizeof(ClientInfo), 0);
227--- squid-2.5.STABLE12/src/comm_select.c.fdc 2003-05-11 19:30:13.000000000 +0200
228+++ squid-2.5.STABLE12/src/comm_select.c 2005-12-06 14:07:43.000000000 +0100
229@@ -66,10 +66,10 @@
230 #if !HAVE_POLL
231 static struct timeval zero_tv;
232 #endif
233-static fd_set global_readfds;
234-static fd_set global_writefds;
235 static int nreadfds;
236 static int nwritefds;
237+static BIT_ARRAY global_readfds;
238+static BIT_ARRAY global_writefds;
239
240 /*
241 * Automatic tuning for incoming requests:
242@@ -171,13 +171,39 @@
243 }
244
245 #if DELAY_POOLS
246+
247+#if FD_CONFIG
248+static int *slowfdarr = NULL;
249+static int slowfdmax;
250+#else
251+static int slowfdarr[SQUID_NUMFD];
252+static int slowfdmax = SQUID_NUMFD;
253+#endif
254+
255 static int slowfdcnt = 0;
256-static int slowfdarr[SQUID_MAXFD];
257+
258+#if FD_CONFIG
259+void
260+comm_slow_fd_init(int fd_num)
261+{
262+ slowfdarr = xmalloc(sizeof(slowfdarr[0])*fd_num);
263+ slowfdmax = fd_num;
264+ slowfdcnt = 0;
265+}
266+
267+void
268+comm_slow_fd_destroy(void)
269+{
270+ xfree(slowfdarr);
271+ slowfdarr = NULL;
272+ slowfdmax = slowfdcnt = 0;
273+}
274+#endif
275
276 static void
277 commAddSlowFd(int fd)
278 {
279- assert(slowfdcnt < SQUID_MAXFD);
280+ assert(slowfdcnt < slowfdmax);
281 slowfdarr[slowfdcnt++] = fd;
282 }
283
284@@ -308,9 +334,13 @@
285 int
286 comm_poll(int msec)
287 {
288- struct pollfd pfds[SQUID_MAXFD];
289+#if FD_CONFIG
290+ struct pollfd *pfds = NULL;
291+#else
292+ struct pollfd pfds[SQUID_NUMFD];
293+#endif
294 #if DELAY_POOLS
295- fd_set slowfds;
296+ BIT_ARRAY slowfds;
297 #endif
298 PF *hdl = NULL;
299 int fd;
300@@ -323,6 +353,12 @@
301 int calldns = 0;
302 static time_t last_timeout = 0;
303 double timeout = current_dtime + (msec / 1000.0);
304+#if FD_CONFIG
305+ pfds = xmalloc(sizeof(pfds[0])*SQUID_NUMFD);
306+#endif
307+#if DELAY_POOLS
308+ BA_INIT(slowfds,SQUID_NUMFD);
309+#endif
310 do {
311 #if !ALARM_UPDATES_TIME
312 double start;
313@@ -332,7 +368,7 @@
314 /* Handle any fs callbacks that need doing */
315 storeDirCallback();
316 #if DELAY_POOLS
317- FD_ZERO(&slowfds);
318+ BA_ZERO(slowfds);
319 #endif
320 if (commCheckICPIncoming)
321 comm_poll_icp_incoming();
322@@ -358,7 +394,7 @@
323 #if DELAY_POOLS
324 case -1:
325 events |= POLLRDNORM;
326- FD_SET(i, &slowfds);
327+ BA_SET(i, slowfds);
328 break;
329 #endif
330 default:
331@@ -378,6 +414,12 @@
332 }
333 if (nfds == 0) {
334 assert(shutting_down);
335+#if DELAY_POOLS
336+ BA_FREE(slowfds);
337+#endif
338+#if FD_CONFIG
339+ xfree(pfds);
340+#endif
341 return COMM_SHUTDOWN;
342 }
343 if (npending)
344@@ -394,6 +436,12 @@
345 continue;
346 debug(5, 0) ("comm_poll: poll failure: %s\n", xstrerror());
347 assert(errno != EINVAL);
348+#if DELAY_POOLS
349+ BA_FREE(slowfds);
350+#endif
351+#if FD_CONFIG
352+ xfree(pfds);
353+#endif
354 return COMM_ERROR;
355 /* NOTREACHED */
356 }
357@@ -437,7 +485,7 @@
358 if (NULL == (hdl = F->read_handler))
359 (void) 0;
360 #if DELAY_POOLS
361- else if (FD_ISSET(fd, &slowfds))
362+ else if (BA_ISSET(fd, slowfds))
363 commAddSlowFd(fd);
364 #endif
365 else {
366@@ -518,10 +566,22 @@
367 getCurrentTime();
368 statCounter.select_time += (current_dtime - start);
369 #endif
370+#if DELAY_POOLS
371+ BA_FREE(slowfds);
372+#endif
373+#if FD_CONFIG
374+ xfree(pfds);
375+#endif
376 return COMM_OK;
377 }
378 while (timeout > current_dtime);
379 debug(5, 8) ("comm_poll: time out: %ld.\n", (long int) squid_curtime);
380+#if DELAY_POOLS
381+ BA_FREE(slowfds);
382+#endif
383+#if FD_CONFIG
384+ xfree(pfds);
385+#endif
386 return COMM_TIMEOUT;
387 }
388
389@@ -646,7 +706,7 @@
390 fd_set pendingfds;
391 fd_set writefds;
392 #if DELAY_POOLS
393- fd_set slowfds;
394+ BIT_ARRAY slowfds;
395 #endif
396 PF *hdl = NULL;
397 int fd;
398@@ -668,6 +728,9 @@
399 struct timeval poll_time;
400 double timeout = current_dtime + (msec / 1000.0);
401 fde *F;
402+#if DELAY_POOLS
403+ BA_INIT(slowfds,SQUID_NUMFD);
404+#endif
405 do {
406 #if !ALARM_UPDATES_TIME
407 double start;
408@@ -675,7 +738,7 @@
409 start = current_dtime;
410 #endif
411 #if DELAY_POOLS
412- FD_ZERO(&slowfds);
413+ BA_ZERO(slowfds);
414 #endif
415 /* Handle any fs callbacks that need doing */
416 storeDirCallback();
417@@ -712,7 +771,7 @@
418 break;
419 #if DELAY_POOLS
420 case -1:
421- FD_SET(fd, &slowfds);
422+ BA_SET(fd, slowfds);
423 break;
424 #endif
425 default:
426@@ -741,6 +800,9 @@
427 #endif
428 if (nreadfds + nwritefds == 0) {
429 assert(shutting_down);
430+#if DELAY_POOLS
431+ BA_FREE(slowfds);
432+#endif
433 return COMM_SHUTDOWN;
434 }
435 if (msec > MAX_POLL_TIME)
436@@ -760,6 +822,9 @@
437 debug(50, 0) ("comm_select: select failure: %s\n",
438 xstrerror());
439 examine_select(&readfds, &writefds);
440+#if DELAY_POOLS
441+ BA_FREE(slowfds);
442+#endif
443 return COMM_ERROR;
444 /* NOTREACHED */
445 }
446@@ -812,7 +877,7 @@
447 if (NULL == (hdl = F->read_handler))
448 (void) 0;
449 #if DELAY_POOLS
450- else if (FD_ISSET(fd, &slowfds))
451+ else if (BA_ISSET(fd, slowfds))
452 commAddSlowFd(fd);
453 #endif
454 else {
455@@ -901,10 +966,16 @@
456 getCurrentTime();
457 statCounter.select_time += (current_dtime - start);
458 #endif
459+#if DELAY_POOLS
460+ BA_FREE(slowfds);
461+#endif
462 return COMM_OK;
463 }
464 while (timeout > current_dtime);
465 debug(5, 8) ("comm_select: time out: %d\n", (int) squid_curtime);
466+#if DELAY_POOLS
467+ BA_FREE(slowfds);
468+#endif
469 return COMM_TIMEOUT;
470 }
471 #endif
472@@ -950,8 +1021,12 @@
473 cachemgrRegister("comm_incoming",
474 "comm_incoming() stats",
475 commIncomingStats, 0, 1);
476- FD_ZERO(&global_readfds);
477- FD_ZERO(&global_writefds);
478+
479+ BA_INIT(global_readfds,SQUID_NUMFD);
480+ BA_INIT(global_writefds,SQUID_NUMFD);
481+
482+ BA_ZERO(global_readfds);
483+ BA_ZERO(global_writefds);
484 nreadfds = nwritefds = 0;
485 }
486
487@@ -977,7 +1052,7 @@
488 fde *F = NULL;
489 struct stat sb;
490 debug(5, 0) ("examine_select: Examining open file descriptors...\n");
491- for (fd = 0; fd < Squid_MaxFD; fd++) {
492+ for (fd = 0; fd < SQUID_NUMFD; fd++) {
493 FD_ZERO(&read_x);
494 FD_ZERO(&write_x);
495 tv.tv_sec = tv.tv_usec = 0;
496@@ -1085,11 +1160,11 @@
497 void
498 commUpdateReadBits(int fd, PF * handler)
499 {
500- if (handler && !FD_ISSET(fd, &global_readfds)) {
501- FD_SET(fd, &global_readfds);
502+ if (handler && !BA_ISSET(fd, global_readfds)) {
503+ BA_SET(fd, global_readfds);
504 nreadfds++;
505- } else if (!handler && FD_ISSET(fd, &global_readfds)) {
506- FD_CLR(fd, &global_readfds);
507+ } else if (!handler && BA_ISSET(fd, global_readfds)) {
508+ BA_CLR(fd, global_readfds);
509 nreadfds--;
510 }
511 }
512@@ -1097,11 +1172,11 @@
513 void
514 commUpdateWriteBits(int fd, PF * handler)
515 {
516- if (handler && !FD_ISSET(fd, &global_writefds)) {
517- FD_SET(fd, &global_writefds);
518+ if (handler && !BA_ISSET(fd, global_writefds)) {
519+ BA_SET(fd, global_writefds);
520 nwritefds++;
521- } else if (!handler && FD_ISSET(fd, &global_writefds)) {
522- FD_CLR(fd, &global_writefds);
523+ } else if (!handler && BA_ISSET(fd, global_writefds)) {
524+ BA_CLR(fd, global_writefds);
525 nwritefds--;
526 }
527 }
528--- squid-2.5.STABLE12/src/globals.h.fdc 2005-06-14 00:26:21.000000000 +0200
529+++ squid-2.5.STABLE12/src/globals.h 2005-12-06 14:07:43.000000000 +0100
530@@ -72,7 +72,6 @@
531 extern int NDnsServersAlloc; /* 0 */
532 extern int NHttpSockets; /* 0 */
533 extern int RESERVED_FD;
534-extern int Squid_MaxFD; /* SQUID_MAXFD */
535 extern int config_lineno; /* 0 */
536 extern int debugLevels[MAX_DEBUG_SECTIONS];
537 extern int do_mallinfo; /* 0 */
538--- squid-2.5.STABLE12/src/ident.c.fdc 2001-04-14 02:03:23.000000000 +0200
539+++ squid-2.5.STABLE12/src/ident.c 2005-12-06 14:07:43.000000000 +0100
540@@ -238,7 +238,7 @@
541 identInit(void)
542 {
543 ident_hash = hash_create((HASHCMP *) strcmp,
544- hashPrime(Squid_MaxFD / 8),
545+ hashPrime(SQUID_NUMFD / 8),
546 hash4);
547 }
548
549--- squid-2.5.STABLE12/src/snmp_agent.c.fdc 2004-06-01 00:39:00.000000000 +0200
550+++ squid-2.5.STABLE12/src/snmp_agent.c 2005-12-06 14:07:43.000000000 +0100
551@@ -289,7 +289,7 @@
552 break;
553 case PERF_SYS_CURUNUSED_FD:
554 Answer = snmp_var_new_integer(Var->name, Var->name_length,
555- (snint) Squid_MaxFD - Number_FD,
556+ (snint) SQUID_NUMFD - Number_FD,
557 SMI_GAUGE32);
558 break;
559 case PERF_SYS_CURRESERVED_FD:
560--- squid-2.5.STABLE12/src/comm.c.fdc 2005-09-10 12:17:55.000000000 +0200
561+++ squid-2.5.STABLE12/src/comm.c 2005-12-06 14:07:43.000000000 +0100
562@@ -239,7 +239,7 @@
563 }
564
565 /*
566- * NOTE: set the listen queue to Squid_MaxFD/4 and rely on the kernel to
567+ * NOTE: set the listen queue to Squid_MAXFD/4 and rely on the kernel to
568 * impose an upper limit. Solaris' listen(3n) page says it has
569 * no limit on this parameter, but sys/socket.h sets SOMAXCONN
570 * to 5. HP-UX currently has a limit of 20. SunOS is 5 and
571@@ -249,9 +249,9 @@
572 comm_listen(int sock)
573 {
574 int x;
575- if ((x = listen(sock, Squid_MaxFD >> 2)) < 0) {
576+ if ((x = listen(sock, SQUID_NUMFD >> 2)) < 0) {
577 debug(50, 0) ("comm_listen: listen(%d, %d): %s\n",
578- Squid_MaxFD >> 2,
579+ SQUID_NUMFD >> 2,
580 sock, xstrerror());
581 return x;
582 }
583@@ -441,7 +441,7 @@
584 fde *F;
585 debug(5, 3) ("commSetTimeout: FD %d timeout %d\n", fd, timeout);
586 assert(fd >= 0);
587- assert(fd < Squid_MaxFD);
588+ assert(fd < SQUID_NUMFD);
589 F = &fd_table[fd];
590 assert(F->flags.open);
591 if (timeout < 0) {
592@@ -637,7 +637,7 @@
593
594 debug(5, 5) ("comm_close: FD %d\n", fd);
595 assert(fd >= 0);
596- assert(fd < Squid_MaxFD);
597+ assert(fd < SQUID_NUMFD);
598 F = &fd_table[fd];
599
600 if (F->flags.closing)
601@@ -862,12 +862,12 @@
602 void
603 comm_init(void)
604 {
605- fd_table = xcalloc(Squid_MaxFD, sizeof(fde));
606+ fd_table = xcalloc(SQUID_NUMFD, sizeof(fde));
607 /* XXX account fd_table */
608 /* Keep a few file descriptors free so that we don't run out of FD's
609 * after accepting a client but before it opens a socket or a file.
610 * Since Squid_MaxFD can be as high as several thousand, don't waste them */
611- RESERVED_FD = XMIN(100, Squid_MaxFD / 4);
612+ RESERVED_FD = XMIN(100, SQUID_NUMFD / 4);
613 CBDATA_INIT_TYPE(ConnectStateData);
614 comm_write_pool = memPoolCreate("CommWriteStateData", sizeof(CommWriteStateData));
615 conn_close_pool = memPoolCreate("close_handler", sizeof(close_handler));
616--- squid-2.5.STABLE12/src/ipc.c.fdc 2001-10-17 22:25:02.000000000 +0200
617+++ squid-2.5.STABLE12/src/ipc.c 2005-12-06 14:07:43.000000000 +0100
618@@ -276,7 +276,7 @@
619 close(t2);
620 close(t3);
621 /* Make sure all other filedescriptors are closed */
622- for (x = 3; x < SQUID_MAXFD; x++)
623+ for (x = 3; x < SQUID_NUMFD; x++)
624 close(x);
625 #if HAVE_SETSID
626 setsid();
627--- squid-2.5.STABLE12/src/main.c.fdc 2005-06-27 23:24:28.000000000 +0200
628+++ squid-2.5.STABLE12/src/main.c 2005-12-06 14:09:21.000000000 +0100
629@@ -350,6 +350,9 @@
630 #else
631 idnsShutdown();
632 #endif
633+#if FD_CONFIG
634+ comm_slow_fd_destroy();
635+#endif
636 redirectShutdown();
637 authenticateShutdown();
638 externalAclShutdown();
639@@ -383,6 +386,9 @@
640 #if USE_WCCP
641 wccpInit();
642 #endif
643+#if FD_CONFIG
644+ comm_slow_fd_init(SQUID_NUMFD);
645+#endif
646 serverConnectionsOpen();
647 if (theOutIcpConnection >= 0) {
648 if (!Config2.Accel.on || Config.onoff.accel_with_proxy)
649@@ -494,7 +500,7 @@
650 version_string,
651 CONFIG_HOST_TYPE);
652 debug(1, 1) ("Process ID %d\n", (int) getpid());
653- debug(1, 1) ("With %d file descriptors available\n", Squid_MaxFD);
654+ debug(1, 1) ("With %d file descriptors available\n", SQUID_NUMFD);
655
656 if (!configured_once)
657 disk_init(); /* disk_init must go before ipcache_init() */
658@@ -506,6 +512,9 @@
659 #else
660 idnsInit();
661 #endif
662+#if FD_CONFIG
663+ comm_slow_fd_init(SQUID_NUMFD);
664+#endif
665 redirectInit();
666 authenticateInit(&Config.authConfig);
667 externalAclInit();
668@@ -600,8 +609,6 @@
669 #endif
670
671 debug_log = stderr;
672- if (FD_SETSIZE < Squid_MaxFD)
673- Squid_MaxFD = FD_SETSIZE;
674
675 #if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_)
676 if ((WIN32_init_err = WIN32_Subsystem_Init()))
677@@ -680,6 +687,8 @@
678 return 0;
679 #endif
680
681+ setMaxFD();
682+
683 /* send signal to running copy and exit */
684 if (opt_send_signal != -1) {
685 /* chroot if configured to run inside chroot */
686@@ -705,7 +714,6 @@
687 }
688 if (!opt_no_daemon)
689 watch_child(argv);
690- setMaxFD();
691
692 /* init comm module */
693 comm_init();
694@@ -977,6 +985,9 @@
695 #endif
696 releaseServerSockets();
697 commCloseAllSockets();
698+#if FD_CONFIG
699+ comm_slow_fd_destroy();
700+#endif
701 authenticateShutdown();
702 #if USE_UNLINKD
703 unlinkdClose();
704--- squid-2.5.STABLE12/src/stat.c.fdc 2005-03-29 11:52:00.000000000 +0200
705+++ squid-2.5.STABLE12/src/stat.c 2005-12-06 14:07:43.000000000 +0100
706@@ -451,7 +451,7 @@
707 "Remote Address",
708 "Description");
709 storeAppendPrintf(sentry, "---- ------ ---- -------- -------- --------------------- ------------------------------\n");
710- for (i = 0; i < Squid_MaxFD; i++) {
711+ for (i = 0; i < SQUID_NUMFD; i++) {
712 f = &fd_table[i];
713 if (!f->flags.open)
714 continue;
715@@ -634,7 +634,7 @@
716
717 storeAppendPrintf(sentry, "File descriptor usage for %s:\n", appname);
718 storeAppendPrintf(sentry, "\tMaximum number of file descriptors: %4d\n",
719- Squid_MaxFD);
720+ SQUID_NUMFD);
721 storeAppendPrintf(sentry, "\tLargest file desc currently in use: %4d\n",
722 Biggest_FD);
723 storeAppendPrintf(sentry, "\tNumber of file desc currently in use: %4d\n",
724@@ -1026,7 +1026,7 @@
725 statHistEnumInit(&C->comm_icp_incoming, INCOMING_ICP_MAX);
726 statHistEnumInit(&C->comm_dns_incoming, INCOMING_DNS_MAX);
727 statHistEnumInit(&C->comm_http_incoming, INCOMING_HTTP_MAX);
728- statHistIntInit(&C->select_fds_hist, 256); /* was SQUID_MAXFD, but it is way too much. It is OK to crop this statistics */
729+ statHistIntInit(&C->select_fds_hist, 256); /* was SQUID_NUMFD, but it is way too much. It is OK to crop this statistics */
730 }
731
732 /* add special cases here as they arrive */
733--- squid-2.5.STABLE12/src/delay_pools.c.fdc 2005-10-20 19:30:31.000000000 +0200
734+++ squid-2.5.STABLE12/src/delay_pools.c 2005-12-06 14:07:43.000000000 +0100
735@@ -89,7 +89,7 @@
736 typedef union _delayPool delayPool;
737
738 static delayPool *delay_data = NULL;
739-static fd_set delay_no_delay;
740+static BIT_ARRAY delay_no_delay;
741 static time_t delay_pools_last_update = 0;
742 static hash_table *delay_id_ptr_hash = NULL;
743 static long memory_used = 0;
744@@ -134,7 +134,8 @@
745 delayPoolsInit(void)
746 {
747 delay_pools_last_update = getCurrentTime();
748- FD_ZERO(&delay_no_delay);
749+ BA_INIT(delay_no_delay,SQUID_NUMFD);
750+ BA_ZERO(delay_no_delay);
751 cachemgrRegister("delay", "Delay Pool Levels", delayPoolStats, 0, 1);
752 }
753
754@@ -169,6 +170,7 @@
755 hashFreeItems(delay_id_ptr_hash, delayIdZero);
756 hashFreeMemory(delay_id_ptr_hash);
757 delay_id_ptr_hash = NULL;
758+ BA_FREE(delay_no_delay);
759 }
760
761 void
762@@ -283,19 +285,19 @@
763 void
764 delaySetNoDelay(int fd)
765 {
766- FD_SET(fd, &delay_no_delay);
767+ BA_SET(fd, delay_no_delay);
768 }
769
770 void
771 delayClearNoDelay(int fd)
772 {
773- FD_CLR(fd, &delay_no_delay);
774+ BA_CLR(fd, delay_no_delay);
775 }
776
777 int
778 delayIsNoDelay(int fd)
779 {
780- return FD_ISSET(fd, &delay_no_delay);
781+ return BA_ISSET(fd, delay_no_delay);
782 }
783
784 static delay_id
785--- squid-2.5.STABLE12/src/squid.h.fdc 2005-03-26 03:50:53.000000000 +0100
786+++ squid-2.5.STABLE12/src/squid.h 2005-12-06 14:07:43.000000000 +0100
787@@ -400,6 +400,20 @@
788 #include "cache_snmp.h"
789 #endif
790
791+#if !HAVE_POLL
792+#define FD_CONFIG 0
793+#endif
794+
795+#if FD_CONFIG
796+#define SQUID_NUMFD (Config.max_filedesc)
797+#define BIT_ARRAY_ACTIVE 1
798+#else
799+#define SQUID_NUMFD SQUID_MAXFD
800+#define BIT_ARRAY_ACTIVE 0
801+#endif
802+
803+#include "bit_array.h"
804+
805 #include "hash.h"
806 #include "rfc1035.h"
807
This page took 0.109154 seconds and 4 git commands to generate.