Index: acconfig.h diff -u acconfig.h:1.11 acconfig.h:1.4.10.8 --- acconfig.h:1.11 Thu Sep 27 00:49:37 2001 +++ acconfig.h Sun Sep 30 13:38:13 2001 @@ -208,6 +208,9 @@ /* Define if you have struct rusage */ #undef HAVE_STRUCT_RUSAGE +/* Define if you have PSAPI.DLL on Windows systems */ +#undef HAVE_WIN32_PSAPI + /* * This makes warnings go away. If you have socklen_t defined in your * /usr/include files, then this should remain undef'd. Otherwise it Index: configure.in diff -u configure.in:1.31 configure.in:1.8.2.21 --- configure.in:1.31 Wed Oct 17 11:51:31 2001 +++ configure.in Fri Oct 19 12:35:03 2001 @@ -60,6 +60,25 @@ ;; esac +dnl check for PSAPI.DLL on cygwin32 platform and add win32.o to squid objects +case "$host_os" in +cygwin|cygwin32) + AC_PATH_PROG(WIN32_PSAPI, psapi.dll, none) + if test "$ac_cv_path_WIN32_PSAPI" = "none"; then + echo "PSAPI.DLL is reccommended to run Squid on Windows NT Platform" + echo "Please see PSAPI.DLL section on doc/win32-relnotes.txt." + WIN32_LIBS="" + else + AC_DEFINE(HAVE_WIN32_PSAPI) + WIN32_LIBS="-lpsapi" + fi + ;; +*) + WIN32_LIBS="" + ;; +esac +AC_SUBST(WIN32_LIBS) + if test -z "$CACHE_HTTP_PORT"; then CACHE_HTTP_PORT="3128" fi Index: doc/win32-relnotes.txt diff -u /dev/null doc/win32-relnotes.txt:1.1.2.2 --- /dev/null Thu Jan 1 01:00:00 1970 +++ doc/win32-relnotes.txt Sat Jun 2 02:48:23 2001 @@ -0,0 +1,19 @@ +WIN32 Squid Relese Notes + + + +PSAPI.DLL (Process Status Helper) Considerations + +The process status helper functions make it easier for you to obtain information about +processes and device drivers running on Microsoft® Windows NT®/Windows® 2000. These +functions are available in PSAPI.DLL, which is distributed in the Microsoft® Platform +Software Development Kit (SDK). The same information is generally available through the +performance data in the registry, but it is more difficult to get to it. PSAPI.DLL is +freely redistributable. +PSAPI.DLL is available only on Windows NT, 2000 and XP. The implementation in Squid is +aware of this, and try to use it only on the rigth platform. +On Windows NT, PSAPI.DLL can be found as component of many applications, if you need it, +you can find it on Windows NT Resource KIT. If you have problem to find it, You can +download it here: http://www.serassio.it/download/psapi.zip +On Windows 2000 it is available installing the Windows 2000 Support Tools, located on the +Support\Tools folder of the installation Windows 2000 CD-ROM. Index: src/Makefile.am diff -u src/Makefile.am:1.6 src/Makefile.am:1.2.6.5 --- src/Makefile.am:1.6 Wed Oct 17 05:30:52 2001 +++ src/Makefile.am Sat Oct 20 02:44:35 2001 @@ -218,6 +218,7 @@ @LIB_MALLOC@ \ @SSLLIB@ \ ../lib/libmiscutil.a \ + @WIN32_LIBS@ \ @XTRA_LIBS@ unlinkd_SOURCES = Index: src/cf_gen.c diff -u src/cf_gen.c:1.10 src/cf_gen.c:1.4.18.6 --- src/cf_gen.c:1.10 Thu Oct 18 13:52:11 2001 +++ src/cf_gen.c Sat Oct 20 01:33:18 2001 @@ -66,7 +66,7 @@ #if HAVE_ASSERT_H #include #endif -#if defined(_SQUID_CYGWIN_) +#if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_) #include #endif #if HAVE_FCNTL_H @@ -152,7 +152,7 @@ perror(input_filename); exit(1); } -#if defined(_SQUID_CYGWIN_) +#if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_) setmode(fileno(fp), O_TEXT); #endif state = sSTART; @@ -333,7 +333,7 @@ perror(output_filename); exit(1); } -#if defined(_SQUID_CYGWIN_) +#if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_) setmode(fileno(fp), O_TEXT); #endif fprintf(fp, @@ -358,7 +358,7 @@ perror(conf_filename); exit(1); } -#if defined(_SQUID_CYGWIN_) +#if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_) setmode(fileno(fp), O_TEXT); #endif gen_conf(entries, fp); Index: src/client.c diff -u src/client.c:1.8 src/client.c:1.3.28.4 --- src/client.c:1.8 Thu Oct 18 13:52:11 2001 +++ src/client.c Sat Oct 20 01:33:18 2001 @@ -200,7 +200,7 @@ xstrerror()); exit(-1); } -#if defined(_SQUID_CYGWIN_) +#if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_) setmode(put_fd, O_BINARY); #endif fstat(put_fd, &sb); Index: src/debug.c diff -u src/debug.c:1.8 src/debug.c:1.3.26.9 --- src/debug.c:1.8 Fri Jun 29 15:34:19 2001 +++ src/debug.c Tue Jul 3 15:04:35 2001 @@ -171,7 +171,7 @@ fflush(stderr); debug_log = stderr; } -#if defined(_SQUID_CYGWIN_) +#if defined(_SQUID_CYGWIN_)||defined(_SQUID_MSWIN_) setmode(fileno(debug_log), O_TEXT); #endif } @@ -231,6 +231,14 @@ snprintf(to, MAXPATHLEN, "%s.%d", debug_log_file, i); rename(from, to); } +/* + * You can't rename open files on Microsoft "operating systems" + * so we close before renaming. + */ +#ifdef _SQUID_MSWIN_ + if (debug_log != stderr) + fclose(debug_log); +#endif /* Rotate the current log to .0 */ if (Config.Log.rotateNumber > 0) { snprintf(to, MAXPATHLEN, "%s.%d", debug_log_file, 0); Index: src/tools.c diff -u src/tools.c:1.16 src/tools.c:1.7.2.20 --- src/tools.c:1.16 Thu Oct 18 13:52:11 2001 +++ src/tools.c Sat Oct 20 01:33:18 2001 @@ -34,6 +34,11 @@ */ #include "squid.h" +#if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_) +#include +#include +#include +#endif #define DEAD_MSG "\ The Squid Cache (version %s) died.\n\ @@ -176,10 +181,45 @@ /* Solaris 2.5 has getrusage() permission bug -- Arjan de Vet */ enter_suid(); #endif +#ifndef _SQUID_MSWIN_ getrusage(RUSAGE_SELF, r); +#endif #ifdef _SQUID_SOLARIS_ leave_suid(); #endif +#if HAVE_WIN32_PSAPI && (defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_)) + 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; + r->ru_utime.tv_usec =(DWORD)(tUser64 / 10); + r->ru_stime.tv_usec =(DWORD)(tKernel64 / 10); + } + } +#endif + if ( GetProcessMemoryInfo( hProcess, &pmc, sizeof(pmc)) ) + { + r->ru_maxrss=(DWORD)(pmc.WorkingSetSize /1024); + r->ru_majflt=pmc.PageFaultCount; + } + CloseHandle( hProcess ); + } +#endif #endif } @@ -924,6 +964,9 @@ xrename(const char *from, const char *to) { debug(21, 2) ("xrename: renaming %s to %s\n", from, to); +#ifdef _SQUID_MSWIN_ + remove(to); +#endif if (0 == rename(from, to)) return 0; debug(21, errno == ENOENT ? 2 : 1) ("xrename: Cannot rename %s to %s: %s\n",