---------------------
PatchSet 3447 
Date: 2001/12/02 20:36:46
Author: serassio
Branch: nt-2_3
Tag: (none) 
Log:
Changed getrusage emulation, added SEARCH http method and Windows 2000 automatic service restart

Members: 
	doc/WIN32-ChangeLog.txt:1.1.2.5->1.1.2.6 
	lib/win32lib.c:1.1.2.6->1.1.2.7 
	src/enums.h:1.1.1.3.4.2.2.2->1.1.1.3.4.2.2.3 
	src/tools.c:1.1.1.3.4.1.2.12->1.1.1.3.4.1.2.13 
	src/url.c:1.1.1.3.4.4.2.4->1.1.1.3.4.4.2.5 
	src/win32.c:1.1.2.8->1.1.2.9 
	win/update.bat:1.1.2.1->1.1.2.2 
	win/squidnt/squidnt.dsp:1.1.2.5->1.1.2.6 

Index: squid/doc/WIN32-ChangeLog.txt
===================================================================
RCS file: /cvsroot/squid-sf//squid/doc/Attic/WIN32-ChangeLog.txt,v
retrieving revision 1.1.2.5
retrieving revision 1.1.2.6
diff -u -r1.1.2.5 -r1.1.2.6
--- squid/doc/WIN32-ChangeLog.txt	29 Sep 2001 08:03:07 -0000	1.1.2.5
+++ squid/doc/WIN32-ChangeLog.txt	2 Dec 2001 20:36:46 -0000	1.1.2.6
@@ -45,3 +45,5 @@
 01 Sep 2001 - Fixed swap.state log files handling - (Guido Serassio)
 08 Sep 2001 - Multiple minor bugs fixes - (Guido Serassio)
 29 Sep 2001 - Merged bugzilla patches: #53, #172, #215, #233 and #241 - (Guido Serassio)
+11 Nov 2001 - Added automatic service restart on Windows 2000 - (Guido Serassio)
+25 Nov 2001 - Added SEARCH http method - (Guido Serassio)
\ No newline at end of file
Index: squid/lib/win32lib.c
===================================================================
RCS file: /cvsroot/squid-sf//squid/lib/win32lib.c,v
retrieving revision 1.1.2.6
retrieving revision 1.1.2.7
diff -u -r1.1.2.6 -r1.1.2.7
--- squid/lib/win32lib.c	12 Sep 2001 20:21:15 -0000	1.1.2.6
+++ squid/lib/win32lib.c	2 Dec 2001 20:36:46 -0000	1.1.2.7
@@ -1,5 +1,5 @@
 /*
- * $Id: win32lib.c,v 1.1.2.6 2001/09/12 20:21:15 serassio Exp $
+ * $Id: win32lib.c,v 1.1.2.7 2001/12/02 20:36:46 serassio Exp $
  *
  * * * * * * * * Legal stuff * * * * * * *
  *
@@ -28,6 +28,7 @@
 #if defined(_SQUID_MSWIN_)
 #include <stdio.h>
 #include <windows.h>
+#include <psapi.h>
 #include <process.h>
 #include <string.h>
 #include <sys/timeb.h>
@@ -42,6 +43,52 @@
 int opterr = 1;
 int optopt;
 
+int WIN32_getrusage(int who, struct rusage *usage)
+{
+#if HAVE_WIN32_PSAPI
+    if ((WIN32_OS_version == _WIN_OS_WINNT) || (WIN32_OS_version == _WIN_OS_WIN2K)
+	|| (WIN32_OS_version == _WIN_OS_WINXP))
+    {
+    	/* On Windows NT/2000 call PSAPI.DLL for process Memory */
+    	/* informations -- Guido Serassio                       */
+    	HANDLE hProcess;
+    	PROCESS_MEMORY_COUNTERS pmc;
+	hProcess = OpenProcess(PROCESS_QUERY_INFORMATION |
+	    PROCESS_VM_READ,
+	    FALSE, GetCurrentProcessId());
+	{
+	/* Microsoft Visual C++ doesn't have getrusage function,  */
+	/* so we get process CPU time information from PSAPI.DLL. */
+	    FILETIME ftCreate, ftExit, ftKernel, ftUser;
+	    if (GetProcessTimes(hProcess, &ftCreate, &ftExit, &ftKernel, &ftUser))
+	    {
+	    	LONGLONG tUser64 = *(LONGLONG *)&ftUser;
+		LONGLONG tKernel64 = *(LONGLONG *)&ftKernel;
+		usage->ru_utime.tv_usec =(DWORD)(tUser64 / 10);
+		usage->ru_stime.tv_usec =(DWORD)(tKernel64 / 10);
+	    }
+	    else
+	    {
+		CloseHandle( hProcess );
+		return -1;
+	    }
+	}
+	if (GetProcessMemoryInfo( hProcess, &pmc, sizeof(pmc)))
+	{
+	    usage->ru_maxrss=(DWORD)(pmc.WorkingSetSize /1024);
+	    usage->ru_majflt=pmc.PageFaultCount;
+	}
+	else
+	{
+	    CloseHandle( hProcess );
+	    return -1;
+	}
+	CloseHandle( hProcess );
+    }
+#endif
+    return 0;
+}
+
 int chroot (const char *dirname)
 {
 	if (SetCurrentDirectory(dirname))
Index: squid/src/enums.h
===================================================================
RCS file: /cvsroot/squid-sf//squid/src/enums.h,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/enums.h	1 Nov 2001 17:31:07 -0000	1.1.1.3.4.2.2.2
+++ squid/src/enums.h	2 Dec 2001 20:36:47 -0000	1.1.1.3.4.2.2.3
@@ -1,6 +1,6 @@
 
 /*
- * $Id: enums.h,v 1.1.1.3.4.2.2.2 2001/11/01 17:31:07 serassio Exp $
+ * $Id: enums.h,v 1.1.1.3.4.2.2.3 2001/12/02 20:36:47 serassio Exp $
  *
  *
  * SQUID Internet Object Cache  http://squid.nlanr.net/Squid/
@@ -384,6 +384,7 @@
     METHOD_BMOVE,
     METHOD_BDELETE,
     METHOD_BPROPFIND,
+    METHOD_SEARCH,
     METHOD_ENUM_END
 };
 typedef unsigned int method_t;
Index: squid/src/tools.c
===================================================================
RCS file: /cvsroot/squid-sf//squid/src/tools.c,v
retrieving revision 1.1.1.3.4.1.2.12
retrieving revision 1.1.1.3.4.1.2.13
diff -u -r1.1.1.3.4.1.2.12 -r1.1.1.3.4.1.2.13
--- squid/src/tools.c	1 Nov 2001 17:31:08 -0000	1.1.1.3.4.1.2.12
+++ squid/src/tools.c	2 Dec 2001 20:36:47 -0000	1.1.1.3.4.1.2.13
@@ -1,6 +1,6 @@
 
 /*
- * $Id: tools.c,v 1.1.1.3.4.1.2.12 2001/11/01 17:31:08 serassio Exp $
+ * $Id: tools.c,v 1.1.1.3.4.1.2.13 2001/12/02 20:36:47 serassio Exp $
  *
  * DEBUG: section 21    Misc Functions
  * AUTHOR: Harvest Derived
@@ -40,10 +40,6 @@
    memory informations
    
  */
-#if defined(_SQUID_CYGWIN_)
-#undef getrusage
-#define getrusage WIN32_getrusage
-#endif
 
 #define DEAD_MSG "\
 The Squid Cache (version %s) died.\n\
Index: squid/src/url.c
===================================================================
RCS file: /cvsroot/squid-sf//squid/src/url.c,v
retrieving revision 1.1.1.3.4.4.2.4
retrieving revision 1.1.1.3.4.4.2.5
diff -u -r1.1.1.3.4.4.2.4 -r1.1.1.3.4.4.2.5
--- squid/src/url.c	29 Sep 2001 07:59:00 -0000	1.1.1.3.4.4.2.4
+++ squid/src/url.c	2 Dec 2001 20:36:47 -0000	1.1.1.3.4.4.2.5
@@ -1,6 +1,6 @@
 
 /*
- * $Id: url.c,v 1.1.1.3.4.4.2.4 2001/09/29 07:59:00 serassio Exp $
+ * $Id: url.c,v 1.1.1.3.4.4.2.5 2001/12/02 20:36:47 serassio Exp $
  *
  * DEBUG: section 23    URL Parsing
  * AUTHOR: Duane Wessels
@@ -57,6 +57,7 @@
     "BMOVE",
     "BDELETE",
     "BPROPFIND",
+    "SEARCH",
     "ERROR"
 };
 
Index: squid/src/win32.c
===================================================================
RCS file: /cvsroot/squid-sf//squid/src/win32.c,v
retrieving revision 1.1.2.8
retrieving revision 1.1.2.9
diff -u -r1.1.2.8 -r1.1.2.9
--- squid/src/win32.c	1 Nov 2001 17:31:08 -0000	1.1.2.8
+++ squid/src/win32.c	2 Dec 2001 20:36:47 -0000	1.1.2.9
@@ -29,8 +29,6 @@
 /* This code compiles only CygWin & Windows NT Port */
 #if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_)
 #include <windows.h>
-#include <psapi.h>
-#include <process.h>
 
 static unsigned int GetOSVersion();
 void WIN32_svcstatusupdate(DWORD);
@@ -62,6 +60,9 @@
 #define WIN32_VERSION  "2.3-STABLE-5"
 #define COMMANDLINE "CommandLine"
 #define CONFIGFILE  "ConfigFile"
+static SC_ACTION Squid_SCAction[1]= { SC_ACTION_RESTART, 60000 };
+static SERVICE_DESCRIPTION Squid_ServiceDescription = {SOFTWARENAME " " SQUID_VERSION " WWW Proxy Server"};
+static SERVICE_FAILURE_ACTIONS Squid_ServiceFailureActions = { 0, NULL, NULL, 1, Squid_SCAction };
 static char REGKEY[256]="SOFTWARE\\"VENDOR"\\"SOFTWARENAME"\\"WIN32_VERSION"\\";
 static char *keys[] = { 
     "SOFTWARE",	    /* key[0] */
@@ -523,28 +524,36 @@
     }
     snprintf(szPath, sizeof(szPath), "%s %s:%s", ServicePath, _WIN_SQUID_SERVICE_OPTION, WIN32_Service_name);
     schSCManager = OpenSCManager(NULL,	/* machine (NULL == local)    */
-	NULL,			/* database (NULL == default) */
-	SC_MANAGER_ALL_ACCESS	/* access required            */
+	NULL,				/* database (NULL == default) */
+	SC_MANAGER_ALL_ACCESS		/* access required            */
 	);
     if (!schSCManager) {    
 	debug(1, 1) ("OpenSCManager failed");
 	exit(1);
     }
     else {
-	schService = CreateService(schSCManager,	/* SCManager database     */
-	    WIN32_Service_name,		/* name of service        */
-	    WIN32_Service_name,		/* name to display        */
-	    SERVICE_ALL_ACCESS,	/* desired access         */
-	    SERVICE_WIN32_OWN_PROCESS,	/* service type           */
-	    SERVICE_AUTO_START,	/* start type             */
-	    SERVICE_ERROR_NORMAL,	/* error control type     */
-	    (const char *) szPath,	/* service's binary       */
-	    NULL,		/* no load ordering group */
-	    NULL,		/* no tag identifier      */
-	    "Tcpip\0Afd\0",		/* dependencies           */
-	    NULL,		/* LocalSystem account    */
-	    NULL);		/* no password            */
+	schService = CreateService(schSCManager,    /* SCManager database     */
+	    WIN32_Service_name,			    /* name of service        */
+	    WIN32_Service_name,			    /* name to display        */
+	    SERVICE_ALL_ACCESS,			    /* desired access         */
+	    SERVICE_WIN32_OWN_PROCESS,		    /* service type           */
+	    SERVICE_AUTO_START,			    /* start type             */
+	    SERVICE_ERROR_NORMAL,		    /* error control type     */
+	    (const char *) szPath,		    /* service's binary       */
+	    NULL,				    /* no load ordering group */
+	    NULL,				    /* no tag identifier      */
+	    "Tcpip\0Afd\0",			    /* dependencies           */
+	    NULL,				    /* LocalSystem account    */
+	    NULL);				    /* no password            */
 	if (schService) {
+	    if ((WIN32_OS_version == _WIN_OS_WIN2K) || (WIN32_OS_version == _WIN_OS_WINXP))
+	    {
+		DWORD dwInfoLevel = SERVICE_CONFIG_DESCRIPTION;
+
+		ChangeServiceConfig2(schService, dwInfoLevel, &Squid_ServiceDescription);
+		dwInfoLevel = SERVICE_CONFIG_FAILURE_ACTIONS;
+		ChangeServiceConfig2(schService, dwInfoLevel, &Squid_ServiceFailureActions);
+	    }
 	    CloseServiceHandle(schService);
 	    /* Now store the config file location in the registry */
 	    if (!ConfigFile)
@@ -677,57 +686,6 @@
 }
 #endif
 
-int WIN32_getrusage(int who, struct rusage *usage)
-{
-#ifdef _SQUID_CYGWIN_
-    getrusage(who, usage);
-#endif
-#if HAVE_WIN32_PSAPI
-    if ((WIN32_OS_version == _WIN_OS_WINNT) || (WIN32_OS_version == _WIN_OS_WIN2K)
-	|| (WIN32_OS_version == _WIN_OS_WINXP))
-    {
-    	/* On Windows NT/2000 call PSAPI.DLL for process Memory */
-    	/* informations -- Guido Serassio                       */
-    	HANDLE hProcess;
-    	PROCESS_MEMORY_COUNTERS pmc;
-	hProcess = OpenProcess(PROCESS_QUERY_INFORMATION |
-	    PROCESS_VM_READ,
-	    FALSE, GetCurrentProcessId());
-#if defined (_SQUID_MSWIN_)
-	{
-	/* Microsoft Visual C++ doesn't have getrusage function,  */
-	/* so we get process CPU time information from PSAPI.DLL. */
-	    FILETIME ftCreate, ftExit, ftKernel, ftUser;
-	    if (GetProcessTimes(hProcess, &ftCreate, &ftExit, &ftKernel, &ftUser))
-	    {
-	    	LONGLONG tUser64 = *(LONGLONG *)&ftUser;
-		LONGLONG tKernel64 = *(LONGLONG *)&ftKernel;
-		usage->ru_utime.tv_usec =(DWORD)(tUser64 / 10);
-		usage->ru_stime.tv_usec =(DWORD)(tKernel64 / 10);
-	    }
-	    else
-	    {
-		CloseHandle( hProcess );
-		return -1;
-	    }
-	}
-#endif
-	if (GetProcessMemoryInfo( hProcess, &pmc, sizeof(pmc)))
-	{
-	    usage->ru_maxrss=(DWORD)(pmc.WorkingSetSize /1024);
-	    usage->ru_majflt=pmc.PageFaultCount;
-	}
-	else
-	{
-	    CloseHandle( hProcess );
-	    return -1;
-	}
-	CloseHandle( hProcess );
-    }
-#endif
-    return 0;
-}
-
 /* The following code section is part of an EXPERIMENTAL native */
 /* Windows NT/2000 Squid port - Compiles only on MS Visual C++  */
 
Index: squid/win/update.bat
===================================================================
RCS file: /cvsroot/squid-sf//squid/win/Attic/update.bat,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- squid/win/update.bat	30 Jun 2001 18:47:21 -0000	1.1.2.1
+++ squid/win/update.bat	2 Dec 2001 20:36:47 -0000	1.1.2.2
@@ -1,5 +1,5 @@
 @echo off
-if %1==release net stop "SquidNT2.3"
+rem if %1==release net stop "SquidNT2.3"
 copy %0\..\squidnt\%1\squid.exe %2\squid.exe
 copy %0\..\dnsserver\%1\dnsserver.dll %2\dnsserver.dll
 copy %0\..\..\auth_modules\NT\%1\nt_auth.dll %2\nt_auth.dll
@@ -8,4 +8,4 @@
 copy %0\..\..\contrib\htpasswd\%1\htpasswd.exe %2\htpasswd.exe
 copy %0\..\cachemgr\%1\cachemgr.exe %2\cgi-bin\cachemgr.cgi
 copy %0\..\..\contrib\chpasswd\%1\chpasswd.exe %2\cgi-bin\chpasswd.cgi
-if %1==release net start "SquidNT2.3"
+rem if %1==release net start "SquidNT2.3"
Index: squid/win/squidnt/squidnt.dsp
===================================================================
RCS file: /cvsroot/squid-sf//squid/win/squidnt/Attic/squidnt.dsp,v
retrieving revision 1.1.2.5
retrieving revision 1.1.2.6
diff -u -r1.1.2.5 -r1.1.2.6
--- squid/win/squidnt/squidnt.dsp	15 Jul 2001 08:49:38 -0000	1.1.2.5
+++ squid/win/squidnt/squidnt.dsp	2 Dec 2001 20:36:47 -0000	1.1.2.6
@@ -56,7 +56,7 @@
 # Begin Special Build Tool
 SOURCE="$(InputPath)"
 PostBuild_Desc=Copy Squid files to run location
-PostBuild_Cmds=..\update.bat release e:\squid
+PostBuild_Cmds=..\update.bat release d:\squid
 # End Special Build Tool
 
 !ELSEIF  "$(CFG)" == "squidnt - Win32 Debug"
@@ -87,7 +87,7 @@
 # Begin Special Build Tool
 SOURCE="$(InputPath)"
 PostBuild_Desc=Copy Squid files to run location
-PostBuild_Cmds=..\update.bat debug e:\squid
+PostBuild_Cmds=..\update.bat debug d:\squid
 # End Special Build Tool
 
 !ENDIF 
