---------------------
PatchSet 2674 
Date: 2001/07/28 10:18:13
Author: serassio
Branch: nt-2_3
Tag: (none) 
Log:
Merge of Andrey's work - Round 1

Members: 
	CONTRIBUTORS:1.1.1.3->1.1.1.3.22.1 
	include/autoconf.h:1.1.2.5->1.1.2.6 
	lib/util.c:1.1.1.3.4.2.2.1->1.1.1.3.4.2.2.2 
	lib/win32lib.c:1.1.2.3->1.1.2.4 
	src/comm_select.c:1.1.1.3.4.2.2.2->1.1.1.3.4.2.2.3 
	src/disk.c:1.1.1.3.4.1.2.5->1.1.1.3.4.1.2.6 
	src/stat.c:1.1.1.3.4.1.2.4->1.1.1.3.4.1.2.5 
	src/store_dir_ufs.c:1.1.1.1.4.1.2.6->1.1.1.1.4.1.2.7 

Index: squid/CONTRIBUTORS
===================================================================
RCS file: /cvsroot/squid-sf//squid/CONTRIBUTORS,v
retrieving revision 1.1.1.3
retrieving revision 1.1.1.3.22.1
diff -u -r1.1.1.3 -r1.1.1.3.22.1
--- squid/CONTRIBUTORS	26 Jan 2000 03:25:00 -0000	1.1.1.3
+++ squid/CONTRIBUTORS	28 Jul 2001 10:18:13 -0000	1.1.1.3.22.1
@@ -70,6 +70,9 @@
 	Niall Doherty <ndoherty@eei.ericsson.se>
 	Pedro Ribeiro <pribeiro@isel.pt>
 	John Dilley <jad@hpl.hp.com>
+	Romeo Anghelache <romeo@andrew.cmu.edu>
+	Guido Serassio <serassio@libero.it>
+	Andrey Shorin <a_shorin@mail.ru>
 
 Development of this caching software is funded by the National Science
 Foundation (grants NCR-9616602 and NCR-9521745).  Paid staff members on
Index: squid/include/autoconf.h
===================================================================
RCS file: /cvsroot/squid-sf//squid/include/Attic/autoconf.h,v
retrieving revision 1.1.2.5
retrieving revision 1.1.2.6
diff -u -r1.1.2.5 -r1.1.2.6
--- squid/include/autoconf.h	15 Jul 2001 08:49:37 -0000	1.1.2.5
+++ squid/include/autoconf.h	28 Jul 2001 10:18:13 -0000	1.1.2.6
@@ -169,7 +169,7 @@
 
 /* Maximum number of open filedescriptors */
 #undef SQUID_MAXFD
-#define SQUID_MAXFD 4096
+#define SQUID_MAXFD 8192
 
 /* UDP send buffer size */
 #undef SQUID_UDP_SO_SNDBUF
Index: squid/lib/util.c
===================================================================
RCS file: /cvsroot/squid-sf//squid/lib/util.c,v
retrieving revision 1.1.1.3.4.2.2.1
retrieving revision 1.1.1.3.4.2.2.2
diff -u -r1.1.1.3.4.2.2.1 -r1.1.1.3.4.2.2.2
--- squid/lib/util.c	6 Jan 2001 12:40:11 -0000	1.1.1.3.4.2.2.1
+++ squid/lib/util.c	28 Jul 2001 10:18:13 -0000	1.1.1.3.4.2.2.2
@@ -1,6 +1,6 @@
 
 /*
- * $Id: util.c,v 1.1.1.3.4.2.2.1 2001/01/06 12:40:11 hno Exp $
+ * $Id: util.c,v 1.1.1.3.4.2.2.2 2001/07/28 10:18:13 serassio Exp $
  *
  * DEBUG: 
  * AUTHOR: Harvest Derived
@@ -607,8 +607,9 @@
 {
     static char xstrerror_buf[BUFSIZ];
     if (errno < 0 || errno >= sys_nerr)
-	return ("Unknown");
-    snprintf(xstrerror_buf, BUFSIZ, "(%d) %s", errno, strerror(errno));
+	snprintf(xstrerror_buf, BUFSIZ, "(%d) Unknown", errno);
+    else
+	snprintf(xstrerror_buf, BUFSIZ, "(%d) %s", errno, strerror(errno));
     return xstrerror_buf;
 }
 
@@ -621,8 +622,9 @@
 {
     static char xbstrerror_buf[BUFSIZ];
     if (err < 0 || err >= sys_nerr)
-	return ("Unknown");
-    snprintf(xbstrerror_buf, BUFSIZ, "(%d) %s", err, strerror(err));
+	snprintf(xbstrerror_buf, BUFSIZ, "(%d) Unknown", errno);
+    else
+	snprintf(xbstrerror_buf, BUFSIZ, "(%d) %s", err, strerror(err));
     return xbstrerror_buf;
 }
 #endif
Index: squid/lib/win32lib.c
===================================================================
RCS file: /cvsroot/squid-sf//squid/lib/win32lib.c,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -r1.1.2.3 -r1.1.2.4
--- squid/lib/win32lib.c	15 Jul 2001 16:58:38 -0000	1.1.2.3
+++ squid/lib/win32lib.c	28 Jul 2001 10:18:13 -0000	1.1.2.4
@@ -1,5 +1,5 @@
 /*
- * $Id: win32lib.c,v 1.1.2.3 2001/07/15 16:58:38 serassio Exp $
+ * $Id: win32lib.c,v 1.1.2.4 2001/07/28 10:18:13 serassio Exp $
  *
  * * * * * * * * Legal stuff * * * * * * *
  *
@@ -276,4 +276,74 @@
 
 #endif /* TESTGETOPT */
 
+static struct _wsaerrtext {
+	int err;
+	const char *errconst;
+	const char *errdesc;
+} _wsaerrtext[] = {
+WSAEACCES,"WSAEACCES","Permission denied.",
+WSAEADDRINUSE,"WSAEADDRINUSE","Address already in use.",
+WSAEADDRNOTAVAIL,"WSAEADDRNOTAVAIL","Cannot assign requested address.",
+WSAEAFNOSUPPORT,"WSAEAFNOSUPPORT","Address family not supported by protocol family.",
+WSAEALREADY,"WSAEALREADY","Operation already in progress.",
+WSAECONNABORTED,"WSAECONNABORTED","Software caused connection abort.",
+WSAECONNREFUSED,"WSAECONNREFUSED","Connection refused.",
+WSAECONNRESET,"WSAECONNRESET","Connection reset by peer.",
+WSAEDESTADDRREQ,"WSAEDESTADDRREQ","Destination address required.",
+WSAEFAULT,"WSAEFAULT","Bad address.",
+WSAEHOSTDOWN,"WSAEHOSTDOWN","Host is down.",
+WSAEHOSTUNREACH,"WSAEHOSTUNREACH","No route to host.",
+WSAEINPROGRESS,"WSAEINPROGRESS","Operation now in progress.",
+WSAEINTR,"WSAEINTR","Interrupted function call.",
+WSAEINVAL,"WSAEINVAL","Invalid argument.",
+WSAEISCONN,"WSAEISCONN","Socket is already connected.",
+WSAEMFILE,"WSAEMFILE","Too many open files.",
+WSAEMSGSIZE,"WSAEMSGSIZE","Message too long.",
+WSAENETDOWN,"WSAENETDOWN","Network is down.",
+WSAENETRESET,"WSAENETRESET","Network dropped connection on reset.",
+WSAENETUNREACH,"WSAENETUNREACH","Network is unreachable.",
+WSAENOBUFS,"WSAENOBUFS","No buffer space available.",
+WSAENOPROTOOPT,"WSAENOPROTOOPT","Bad protocol option.",
+WSAENOTCONN,"WSAENOTCONN","Socket is not connected.",
+WSAENOTSOCK,"WSAENOTSOCK","Socket operation on nonsocket.",
+WSAEOPNOTSUPP,"WSAEOPNOTSUPP","Operation not supported.",
+WSAEPFNOSUPPORT,"WSAEPFNOSUPPORT","Protocol family not supported.",
+WSAEPROCLIM,"WSAEPROCLIM","Too many processes.",
+WSAEPROTONOSUPPORT,"WSAEPROTONOSUPPORT","Protocol not supported.",
+WSAEPROTOTYPE,"WSAEPROTOTYPE","Protocol wrong type for socket.",
+WSAESHUTDOWN,"WSAESHUTDOWN","Cannot send after socket shutdown.",
+WSAESOCKTNOSUPPORT,"WSAESOCKTNOSUPPORT","Socket type not supported.",
+WSAETIMEDOUT,"WSAETIMEDOUT","Connection timed out.",
+WSAEWOULDBLOCK,"WSAEWOULDBLOCK","Resource temporarily unavailable.",
+WSANOTINITIALISED,"WSANOTINITIALISED","Successful WSAStartup not yet performed.",
+WSASYSNOTREADY,"WSASYSNOTREADY","Network subsystem is unavailable.",
+WSAVERNOTSUPPORTED,"WSAVERNOTSUPPORTED","Winsock.dll version out of range.",
+WSAEDISCON,"WSAEDISCON","Graceful shutdown in progress."
+};
+
+/*
+ * wsastrerror() - description of WSAGetLastError()
+ */
+const char *
+wsastrerror(int err)
+{
+    static char xwsaerror_buf[BUFSIZ];
+/*	int err = WSAGetLastError();*/
+	int i, errind = -1;
+
+	if ( err == 0 )
+		return "(0) No error.";
+	for ( i = 0; i < sizeof(_wsaerrtext)/sizeof(struct _wsaerrtext); i++ ) {
+		if ( _wsaerrtext[i].err != err )
+			continue;
+		errind = i;
+		break;
+	}
+    if (errind == -1)
+	return ("Unknown");
+	assert(err == _wsaerrtext[errind].err);
+    snprintf(xwsaerror_buf, BUFSIZ, "(%d) %s, %s", err, _wsaerrtext[errind].errconst, _wsaerrtext[errind].errdesc);
+    return xwsaerror_buf;
+}
+
 #endif
Index: squid/src/comm_select.c
===================================================================
RCS file: /cvsroot/squid-sf//squid/src/comm_select.c,v
retrieving revision 1.1.1.3.4.2.2.2
retrieving revision 1.1.1.3.4.2.2.3
diff -u -r1.1.1.3.4.2.2.2 -r1.1.1.3.4.2.2.3
--- squid/src/comm_select.c	1 Jul 2001 16:26:55 -0000	1.1.1.3.4.2.2.2
+++ squid/src/comm_select.c	28 Jul 2001 10:18:13 -0000	1.1.1.3.4.2.2.3
@@ -1,6 +1,6 @@
 
 /*
- * $Id: comm_select.c,v 1.1.1.3.4.2.2.2 2001/07/01 16:26:55 serassio Exp $
+ * $Id: comm_select.c,v 1.1.1.3.4.2.2.3 2001/07/28 10:18:13 serassio Exp $
  *
  * DEBUG: section 5     Socket Functions
  *
@@ -724,9 +724,21 @@
 	xmemcpy(&writesds, &global_writesds,sizeof(global_writesds));
 	xmemcpy(&errsds, &global_writesds,sizeof(global_writesds));
 	for (j = 0; j < (int) readsds.fd_count; j++) {
-		fd=readsds.fd_array[j];
-		if (commDeferRead(fd))
-		    FD_CLR((SOCKET) fd, &readsds);
+	    fd=readsds.fd_array[j];
+	    switch (commDeferRead(fd)) {
+	    case 0:
+		break;
+	    case 1:
+		FD_CLR((SOCKET) fd, &readsds);
+		break;
+#if DELAY_POOLS
+	    case -1:
+		FD_SET(fd, &slowfds);
+		break;
+#endif
+	    default:
+		fatalf("bad return value from commDeferRead(FD %d)\n", fd);
+	    }
 	}
 #else
 	xmemcpy(&readfds, &global_readfds,
Index: squid/src/disk.c
===================================================================
RCS file: /cvsroot/squid-sf//squid/src/disk.c,v
retrieving revision 1.1.1.3.4.1.2.5
retrieving revision 1.1.1.3.4.1.2.6
diff -u -r1.1.1.3.4.1.2.5 -r1.1.1.3.4.1.2.6
--- squid/src/disk.c	10 Jul 2001 19:42:14 -0000	1.1.1.3.4.1.2.5
+++ squid/src/disk.c	28 Jul 2001 10:18:13 -0000	1.1.1.3.4.1.2.6
@@ -1,6 +1,6 @@
 
 /*
- * $Id: disk.c,v 1.1.1.3.4.1.2.5 2001/07/10 19:42:14 serassio Exp $
+ * $Id: disk.c,v 1.1.1.3.4.1.2.6 2001/07/28 10:18:13 serassio Exp $
  *
  * DEBUG: section 6     Disk I/O Routines
  * AUTHOR: Harvest Derived
@@ -79,7 +79,7 @@
 	else
 	    strcpy(fmode,"rb");
 	fbuf=fopen(path,fmode);
-    fd = fileno(fbuf);
+    fd = (fbuf != NULL) ? fileno(fbuf) : -1;
 #else
     mode |= SQUID_NONBLOCK;
     errno = 0;
@@ -321,7 +321,7 @@
     off_t file_offset,
     void *ptr_to_buf,
     int len,
-    DWCB handle,
+    DWCB * handle,
     void *handle_data,
     FREE * free_func)
 {
@@ -457,4 +457,3 @@
     /* NOTREACHED */
 }
 #endif
-
Index: squid/src/stat.c
===================================================================
RCS file: /cvsroot/squid-sf//squid/src/stat.c,v
retrieving revision 1.1.1.3.4.1.2.4
retrieving revision 1.1.1.3.4.1.2.5
diff -u -r1.1.1.3.4.1.2.4 -r1.1.1.3.4.1.2.5
--- squid/src/stat.c	15 Jul 2001 16:58:38 -0000	1.1.1.3.4.1.2.4
+++ squid/src/stat.c	28 Jul 2001 10:18:13 -0000	1.1.1.3.4.1.2.5
@@ -1,6 +1,6 @@
 
 /*
- * $Id: stat.c,v 1.1.1.3.4.1.2.4 2001/07/15 16:58:38 serassio Exp $
+ * $Id: stat.c,v 1.1.1.3.4.1.2.5 2001/07/28 10:18:13 serassio Exp $
  *
  * DEBUG: section 18    Cache Manager Statistics
  * AUTHOR: Harvest Derived
@@ -634,7 +634,15 @@
 	RESERVED_FD);
     storeAppendPrintf(sentry, "\tStore Disk files open:                %4d\n",
 	store_open_disk_fd);
-
+#ifdef _SQUID_MSWIN_
+    storeAppendPrintf(sentry, "Socket descriptor usage for %s:\n", appname);
+    storeAppendPrintf(sentry, "\tMaximum number of socket descriptors:   %4d\n",
+	Squid_MaxFD);
+    storeAppendPrintf(sentry, "\tLargest socket desc currently in use:   %4d\n",
+	Biggest_SD);
+    storeAppendPrintf(sentry, "\tNumber of socket desc currently in use: %4d\n",
+	Number_SD);
+#endif
     storeAppendPrintf(sentry, "Internal Data Structures:\n");
     storeAppendPrintf(sentry, "\t%6d StoreEntries\n",
 	memInUse(MEM_STOREENTRY));
Index: squid/src/store_dir_ufs.c
===================================================================
RCS file: /cvsroot/squid-sf//squid/src/Attic/store_dir_ufs.c,v
retrieving revision 1.1.1.1.4.1.2.6
retrieving revision 1.1.1.1.4.1.2.7
diff -u -r1.1.1.1.4.1.2.6 -r1.1.1.1.4.1.2.7
--- squid/src/store_dir_ufs.c	15 Jul 2001 16:58:38 -0000	1.1.1.1.4.1.2.6
+++ squid/src/store_dir_ufs.c	28 Jul 2001 10:18:13 -0000	1.1.1.1.4.1.2.7
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_dir_ufs.c,v 1.1.1.1.4.1.2.6 2001/07/15 16:58:38 serassio Exp $
+ * $Id: store_dir_ufs.c,v 1.1.1.1.4.1.2.7 2001/07/28 10:18:13 serassio Exp $
  *
  * DEBUG: section 47    Store Directory Routines
  * AUTHOR: Duane Wessels
@@ -787,11 +787,7 @@
     }
     sd->u.ufs.swaplog_fd = fd;
     /* open a read-only stream of the old log */
-//#ifdef _SQUID_MSWIN_
-//    fp = fopen(swaplog_path, "rb");
-//#else
     fp = fopen(swaplog_path, "r");
-//#endif
     if (fp == NULL) {
 	debug(50, 0) ("%s: %s\n", swaplog_path, xstrerror());
 	fatal("Failed to open swap log for reading");
