[grahame@ucs.uwa.edu.au: Patch to squid HEAD]

From: Adrian Chadd <adrian@dont-contact.us>
Date: Thu, 15 Nov 2001 06:50:55 -0700

Review?

Adrian

----- Forwarded message from Grahame Bowland <grahame@ucs.uwa.edu.au> -----

Subject: Patch to squid HEAD
From: Grahame Bowland <grahame@ucs.uwa.edu.au>
To: adrian@squid-cache.org
X-Mailer: Evolution/0.99.0 (Preview Release)
Date: 15 Nov 2001 12:40:43 +0800

Hi Adrian,

Attempting to get onto squid-dev, but until then I'll send patches to
you :) This patch removes the dependency on the OS specified FD_SETSIZE
when using polled I/O. Basically it removes fd_set from the delay pools
code and replaces it with an array of chars, as that was the only thing
tying us down to the FD_SETSIZE limit for Squid_MaxFD.

We've been running with this on styx for a few days, since 1024
filedescriptors was too small.

Anyway, patch attached and I used diff -u this time :)

-- 
Grahame Bowland                      Email: grahame@ucs.uwa.edu.au
University Communications Services   Phone: +61 8 9380 1175
The University of Western Australia    Fax: +61 8 9380 1109
? conf.sh
? fdset.patch
? config.log
? config.cache
? config.status
? Makefile
? contrib/Makefile
? errors/Makefile
? icons/Makefile
? icons/anthony-binhex.gif
? icons/anthony-bomb.gif
? icons/anthony-box.gif
? icons/anthony-box2.gif
? icons/anthony-c.gif
? icons/anthony-compressed.gif
? icons/anthony-dir.gif
? icons/anthony-dirup.gif
? icons/anthony-dvi.gif
? icons/anthony-f.gif
? icons/anthony-image.gif
? icons/anthony-image2.gif
? icons/anthony-layout.gif
? icons/anthony-link.gif
? icons/anthony-movie.gif
? icons/anthony-pdf.gif
? icons/anthony-portal.gif
? icons/anthony-ps.gif
? icons/anthony-quill.gif
? icons/anthony-script.gif
? icons/anthony-sound.gif
? icons/anthony-tar.gif
? icons/anthony-tex.gif
? icons/anthony-text.gif
? icons/anthony-unknown.gif
? icons/anthony-xbm.gif
? icons/anthony-xpm.gif
? include/autoconf.h
? include/stamp-h1
? include/stamp-h
? lib/Makefile
? lib/.deps
? scripts/Makefile
? scripts/RunCache
? scripts/RunAccel
? snmplib/Makefile
? snmplib/.deps
? src/Makefile
? src/.deps
? src/cf_gen_defines.h
? src/cf.data
? src/cf_gen
? src/cf_parser.h
? src/squid.conf.default
? src/globals.c
? src/string_arrays.c
? src/repl_modules.c
? src/auth_modules.c
? src/store_modules.c
? src/squid
? src/client
? src/unlinkd
? src/cachemgr
? src/auth/Makefile
? src/auth/.deps
? src/auth/basic/Makefile
? src/auth/basic/.dirstamp
? src/auth/basic/helpers/Makefile
? src/auth/basic/helpers/LDAP/Makefile
? src/auth/basic/helpers/LDAP/.deps
? src/auth/basic/helpers/MSNT/Makefile
? src/auth/basic/helpers/MSNT/.deps
? src/auth/basic/helpers/NCSA/Makefile
? src/auth/basic/helpers/NCSA/.deps
? src/auth/basic/helpers/PAM/Makefile
? src/auth/basic/helpers/PAM/.deps
? src/auth/basic/helpers/SMB/Makefile
? src/auth/basic/helpers/SMB/.deps
? src/auth/basic/helpers/YP/Makefile
? src/auth/basic/helpers/YP/.deps
? src/auth/basic/helpers/getpwnam/Makefile
? src/auth/basic/helpers/getpwnam/.deps
? src/auth/basic/helpers/multi-domain-NTLM/Makefile
? src/auth/digest/Makefile
? src/auth/digest/helpers/Makefile
? src/auth/digest/helpers/password/Makefile
? src/auth/digest/helpers/password/.deps
? src/auth/ntlm/Makefile
? src/auth/ntlm/helpers/Makefile
? src/auth/ntlm/helpers/NTLMSSP/Makefile
? src/auth/ntlm/helpers/NTLMSSP/.deps
? src/auth/ntlm/helpers/NTLMSSP/smbval/Makefile
? src/auth/ntlm/helpers/NTLMSSP/smbval/.deps
? src/auth/ntlm/helpers/fakeauth/Makefile
? src/auth/ntlm/helpers/fakeauth/.deps
? src/auth/ntlm/helpers/no_check/Makefile
? src/fs/Makefile
? src/fs/.deps
? src/fs/aufs/Makefile
? src/fs/aufs/.dirstamp
? src/fs/coss/Makefile
? src/fs/diskd/Makefile
? src/fs/diskd/.deps
? src/fs/null/Makefile
? src/fs/ufs/Makefile
? src/fs/ufs/.dirstamp
? src/repl/Makefile
? src/repl/.deps
? src/repl/heap/Makefile
? src/repl/heap/.dirstamp
? src/repl/lru/Makefile
Index: src/comm_select.c
===================================================================
RCS file: /squid/squid/src/comm_select.c,v
retrieving revision 1.53
diff -u -r1.53 comm_select.c
--- src/comm_select.c	2001/10/24 06:55:44	1.53
+++ src/comm_select.c	2001/11/15 04:36:54
@@ -310,7 +310,7 @@
 {
     struct pollfd pfds[SQUID_MAXFD];
 #if DELAY_POOLS
-    fd_set slowfds;
+    char slowfds[SQUID_MAXFD];
 #endif
     PF *hdl = NULL;
     int fd;
@@ -332,7 +332,7 @@
 	/* Handle any fs callbacks that need doing */
 	storeDirCallback();
 #if DELAY_POOLS
-	FD_ZERO(&slowfds);
+        bzero(slowfds, sizeof(slowfds));
 #endif
 	if (commCheckICPIncoming)
 	    comm_poll_icp_incoming();
@@ -358,7 +358,11 @@
 #if DELAY_POOLS
 		case -1:
 		    events |= POLLRDNORM;
-		    FD_SET(i, &slowfds);
+                    if (i < Squid_MaxFD) {
+		        slowfds[i] = 1;
+                    } else {
+                        debug(5, 0) ("WARNING: tried to set FD %d > Squid_MaxFD in slowfds.", i);
+                    }
 		    break;
 #endif
 		default:
@@ -437,7 +441,7 @@
 		if (NULL == (hdl = F->read_handler))
 		    (void) 0;
 #if DELAY_POOLS
-		else if (FD_ISSET(fd, &slowfds))
+                else if (slowfds[fd])
 		    commAddSlowFd(fd);
 #endif
 		else {
@@ -646,7 +650,7 @@
     fd_set pendingfds;
     fd_set writefds;
 #if DELAY_POOLS
-    fd_set slowfds;
+    char slowfds[SQUID_MAXFD];
 #endif
     PF *hdl = NULL;
     int fd;
@@ -673,7 +677,7 @@
 	getCurrentTime();
 #endif
 #if DELAY_POOLS
-	FD_ZERO(&slowfds);
+        bzero(slowfds, sizeof(slowfds));
 #endif
 	/* Handle any fs callbacks that need doing */
 	storeDirCallback();
@@ -709,7 +713,11 @@
 		    break;
 #if DELAY_POOLS
 		case -1:
-		    FD_SET(fd, &slowfds);
+                    if (i < Squid_MaxFD) {
+		        slowfds[i] = 1;
+                    } else {
+                        debug(5, 0) ("WARNING: tried to set FD %d > Squid_MaxFD in slowfds.");
+                    }
 		    break;
 #endif
 		default:
@@ -813,7 +821,7 @@
 		if (NULL == (hdl = F->read_handler))
 		    (void) 0;
 #if DELAY_POOLS
-		else if (FD_ISSET(fd, &slowfds))
+		else if (slowfds[fd])
 		    commAddSlowFd(fd);
 #endif
 		else {
Index: src/delay_pools.c
===================================================================
RCS file: /squid/squid/src/delay_pools.c,v
retrieving revision 1.19
diff -u -r1.19 delay_pools.c
--- src/delay_pools.c	2001/03/19 06:18:42	1.19
+++ src/delay_pools.c	2001/11/15 04:36:55
@@ -89,7 +89,7 @@
 typedef union _delayPool delayPool;
 
 static delayPool *delay_data = NULL;
-static fd_set delay_no_delay;
+static char delay_no_delay[SQUID_MAXFD];
 static time_t delay_pools_last_update = 0;
 static hash_table *delay_id_ptr_hash = NULL;
 static long memory_used = 0;
@@ -134,7 +134,7 @@
 delayPoolsInit(void)
 {
     delay_pools_last_update = getCurrentTime();
-    FD_ZERO(&delay_no_delay);
+    bzero(delay_no_delay, sizeof(delay_no_delay));
     cachemgrRegister("delay", "Delay Pool Levels", delayPoolStats, 0, 1);
 }
 
@@ -283,19 +283,32 @@
 void
 delaySetNoDelay(int fd)
 {
-    FD_SET(fd, &delay_no_delay);
+    if (fd < Squid_MaxFD) {
+        delay_no_delay[fd] = 1;
+    } else {
+	debug(77, 1) ("delaySetNoDelay: can't set fd %d, too high\n", fd);
+    }
 }
 
 void
 delayClearNoDelay(int fd)
 {
-    FD_CLR(fd, &delay_no_delay);
+    if (fd < Squid_MaxFD) {
+        delay_no_delay[fd] = 0;
+    } else {
+	debug(77, 1) ("delayClearNoDelay: can't clear fd %d, too high\n", fd);
+    }
 }
 
 int
 delayIsNoDelay(int fd)
 {
-    return FD_ISSET(fd, &delay_no_delay);
+    if (fd < Squid_MaxFD) {
+        return delay_no_delay[fd];
+    } else {
+        debug(77, 1) ("delayIsNoDelay: can't check fd %d, too high\n", fd);
+        return 0;
+    }
 }
 
 static delay_id
Index: src/main.c
===================================================================
RCS file: /squid/squid/src/main.c,v
retrieving revision 1.345
diff -u -r1.345 main.c
--- src/main.c	2001/10/24 06:55:44	1.345
+++ src/main.c	2001/11/15 04:36:56
@@ -573,8 +573,13 @@
 #endif
 
     debug_log = stderr;
+#if !HAVE_POLL
+/* the poll code should now never use fd_set, so we 
+ * need only worry if using another method
+ */
     if (FD_SETSIZE < Squid_MaxFD)
 	Squid_MaxFD = FD_SETSIZE;
+#endif
 
 #if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_)
     if ((WIN32_init_err = WIN32_Subsystem_Init()))
----- End forwarded message -----
Received on Thu Nov 15 2001 - 06:50:56 MST

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:14:38 MST