--------------------- PatchSet 1033 Date: 2004/06/21 21:35:04 Author: serassio Branch: nt Tag: (none) Log: Forward port of latest WIN32 changes from nt-2_5 branch Members: lib/win32lib.c:1.2.18.3->1.2.18.4 port/win32/cf_gen/cf_gen.dsp:1.2.18.1->1.2.18.2 src/cache_manager.cc:1.5.2.3->1.5.2.4 src/fde.cc:1.3->1.3.2.1 src/ipc.cc:1.8.2.5->1.8.2.6 src/protos.h:1.19.2.25->1.19.2.26 src/win32.cc:1.4.2.8->1.4.2.9 src/fs/awin32/aiops.cc:1.2.18.3->1.2.18.4 src/fs/awin32/async_io.cc:1.2.18.2->1.2.18.3 src/fs/awin32/store_asyncufs.h:1.2.18.2->1.2.18.3 src/fs/awin32/store_io_aufs.cc:1.2.18.2->1.2.18.3 Index: squid3/lib/win32lib.c =================================================================== RCS file: /cvsroot/squid-sf//squid3/lib/win32lib.c,v retrieving revision 1.2.18.3 retrieving revision 1.2.18.4 diff -u -r1.2.18.3 -r1.2.18.4 --- squid3/lib/win32lib.c 3 Aug 2003 17:12:01 -0000 1.2.18.3 +++ squid3/lib/win32lib.c 21 Jun 2004 21:35:04 -0000 1.2.18.4 @@ -1,5 +1,5 @@ /* - * $Id: win32lib.c,v 1.2.18.3 2003/08/03 17:12:01 serassio Exp $ + * $Id: win32lib.c,v 1.2.18.4 2004/06/21 21:35:04 serassio Exp $ * * * * * * * * * Legal stuff * * * * * * * * @@ -50,6 +50,9 @@ #include "squid_windows.h" #include #include +#if HAVE_WIN32_PSAPI +#include +#endif THREADLOCAL int ws32_result; LPCRITICAL_SECTION dbg_mutex = NULL; @@ -109,21 +112,54 @@ return GetLastError(); } -int kill(pid_t pid, int sig) +void GetProcessName(pid_t pid, char * ProcessName) { - HANDLE hProcess; + HANDLE hProcess; + + strcpy(ProcessName, "unknown"); +#if HAVE_WIN32_PSAPI + /* Get a handle to the process. */ + hProcess = OpenProcess( PROCESS_QUERY_INFORMATION | + PROCESS_VM_READ, + FALSE, pid ); + /* Get the process name. */ + if (NULL != hProcess) { + HMODULE hMod; + DWORD cbNeeded; + + if (EnumProcessModules(hProcess, &hMod, sizeof(hMod), &cbNeeded)) + GetModuleBaseName(hProcess, hMod, ProcessName, sizeof(ProcessName)); + else { + CloseHandle(hProcess); + return; + } + } else + return; + CloseHandle(hProcess); +#endif +} - if (sig == 0) { - if ((hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | - PROCESS_VM_READ, - FALSE, pid)) == NULL) - return -1; - else { - CloseHandle(hProcess); - return 0; - } +int kill(pid_t pid, int sig) +{ + HANDLE hProcess; + char MyProcessName[MAX_PATH]; + char ProcessNameToCheck[MAX_PATH]; + + if (sig == 0) { + if ((hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | + PROCESS_VM_READ, + FALSE, pid)) == NULL) + return -1; + else { + CloseHandle(hProcess); + GetProcessName(getpid(), MyProcessName); + GetProcessName(pid, ProcessNameToCheck); + if (strcmp(MyProcessName, ProcessNameToCheck) == 0) + return 0; + return -1; } - else return 0; + } + else return 0; } int gettimeofday( struct timeval * pcur_time,void * tz){ Index: squid3/port/win32/cf_gen/cf_gen.dsp =================================================================== RCS file: /cvsroot/squid-sf//squid3/port/win32/cf_gen/Attic/cf_gen.dsp,v retrieving revision 1.2.18.1 retrieving revision 1.2.18.2 diff -u -r1.2.18.1 -r1.2.18.2 --- squid3/port/win32/cf_gen/cf_gen.dsp 25 Feb 2003 02:48:42 -0000 1.2.18.1 +++ squid3/port/win32/cf_gen/cf_gen.dsp 21 Jun 2004 21:35:05 -0000 1.2.18.2 @@ -50,7 +50,7 @@ # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 ws2_32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 ws2_32.lib psapi.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "cf_gen - Win32 Debug" @@ -74,7 +74,7 @@ # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 ws2_32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 ws2_32.lib psapi.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF Index: squid3/src/cache_manager.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/cache_manager.cc,v retrieving revision 1.5.2.3 retrieving revision 1.5.2.4 diff -u -r1.5.2.3 -r1.5.2.4 --- squid3/src/cache_manager.cc 3 Sep 2003 10:37:29 -0000 1.5.2.3 +++ squid3/src/cache_manager.cc 21 Jun 2004 21:35:05 -0000 1.5.2.4 @@ -1,6 +1,6 @@ /* - * $Id: cache_manager.cc,v 1.5.2.3 2003/09/03 10:37:29 serassio Exp $ + * $Id: cache_manager.cc,v 1.5.2.4 2004/06/21 21:35:05 serassio Exp $ * * DEBUG: section 16 Cache Manager Objects * AUTHOR: Duane Wessels @@ -83,6 +83,7 @@ static const char *cachemgrActionProtection(const action_table * at); static OBJH cachemgrShutdown; static OBJH cachemgrReconfigure; +static OBJH cachemgrRotate; #if defined(_SQUID_MSWIN_) && defined(_DEBUG) static OBJH cachemgrBreak; #endif @@ -358,6 +359,14 @@ storeAppendPrintf(sentry, "Reconfiguring Squid Process ...."); } +static void +cachemgrRotate(StoreEntry * sentry) +{ + debug(16, 0) ("Rotate by command.\n"); + rotate_logs(SIGUSR1); + storeAppendPrintf(sentry, "Rotating Squid Logs ...."); +} + #if defined(_SQUID_MSWIN_) && defined(_DEBUG) static void cachemgrBreak(StoreEntry * sentry) @@ -441,6 +450,9 @@ cachemgrRegister("reconfigure", "Reconfigure the Squid Process", cachemgrReconfigure, 1, 1); + cachemgrRegister("rotate", + "Rotate Squid Logs", + cachemgrRotate, 1, 1); #if defined(_SQUID_MSWIN_) && defined(_DEBUG) cachemgrRegister("break", Index: squid3/src/fde.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/fde.cc,v retrieving revision 1.3 retrieving revision 1.3.2.1 diff -u -r1.3 -r1.3.2.1 --- squid3/src/fde.cc 22 Feb 2003 03:14:33 -0000 1.3 +++ squid3/src/fde.cc 21 Jun 2004 21:35:05 -0000 1.3.2.1 @@ -1,6 +1,6 @@ /* - * $Id: fde.cc,v 1.3 2003/02/22 03:14:33 squidadm Exp $ + * $Id: fde.cc,v 1.3.2.1 2004/06/21 21:35:05 serassio Exp $ * * DEBUG: section ?? FDE * AUTHOR: Robert Collins @@ -53,8 +53,14 @@ if (!flags.open) return; +#ifdef _SQUID_MSWIN_ + storeAppendPrintf(&dumpEntry, "%4d 0x%-8lX %-6.6s %4d %7d%c %7d%c %-21s %s\n", + fdNumber, + win32.handle, +#else storeAppendPrintf(&dumpEntry, "%4d %-6.6s %4d %7d%c %7d%c %-21s %s\n", fdNumber, +#endif fdTypeStr[type], timeout_handler ? (int) (timeout - squid_curtime) / 60 : 0, bytes_read, @@ -70,7 +76,14 @@ { int i; storeAppendPrintf(dumpEntry, "Active file descriptors:\n"); +#ifdef _SQUID_MSWIN_ + storeAppendPrintf(dumpEntry, "%-4s %-10s %-6s %-4s %-7s* %-7s* %-21s %s\n", + "File", + "Handle", +#else storeAppendPrintf(dumpEntry, "%-4s %-6s %-4s %-7s* %-7s* %-21s %s\n", + "File", +#endif "File", "Type", "Tout", @@ -78,7 +91,11 @@ "Nwrite", "Remote Address", "Description"); +#ifdef _SQUID_MSWIN_ + storeAppendPrintf(dumpEntry, "---- ---------- ------ ---- -------- -------- --------------------- ------------------------------\n"); +#else storeAppendPrintf(dumpEntry, "---- ------ ---- -------- -------- --------------------- ------------------------------\n"); +#endif for (i = 0; i < Squid_MaxFD; i++) { fd_table[i].dumpStats(*dumpEntry, i); Index: squid3/src/ipc.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/ipc.cc,v retrieving revision 1.8.2.5 retrieving revision 1.8.2.6 diff -u -r1.8.2.5 -r1.8.2.6 --- squid3/src/ipc.cc 18 Aug 2003 16:21:34 -0000 1.8.2.5 +++ squid3/src/ipc.cc 21 Jun 2004 21:35:05 -0000 1.8.2.6 @@ -1,6 +1,6 @@ /* - * $Id: ipc.cc,v 1.8.2.5 2003/08/18 16:21:34 serassio Exp $ + * $Id: ipc.cc,v 1.8.2.6 2004/06/21 21:35:05 serassio Exp $ * * DEBUG: section 54 Interprocess Communication * AUTHOR: Duane Wessels @@ -1853,7 +1853,7 @@ debug(54, 3) ("ipc(%s,%d): request for shutdown received from parent. Exiting...\n", niceprog, pid); - TerminateProcess(hProcess, 0); +// TerminateProcess(hProcess, 0); return; } Index: squid3/src/protos.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/protos.h,v retrieving revision 1.19.2.25 retrieving revision 1.19.2.26 diff -u -r1.19.2.25 -r1.19.2.26 --- squid3/src/protos.h 5 Apr 2004 17:32:08 -0000 1.19.2.25 +++ squid3/src/protos.h 21 Jun 2004 21:35:05 -0000 1.19.2.26 @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.19.2.25 2004/04/05 17:32:08 serassio Exp $ + * $Id: protos.h,v 1.19.2.26 2004/06/21 21:35:05 serassio Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -1038,6 +1038,7 @@ #endif /* _SQUID_WIN32_ */ #ifdef _SQUID_MSWIN_ +SQUIDCEXTERN int WIN32_pipe(int[2]); SQUIDCEXTERN int WIN32_getrusage(int, struct rusage *); #endif Index: squid3/src/win32.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/win32.cc,v retrieving revision 1.4.2.8 retrieving revision 1.4.2.9 diff -u -r1.4.2.8 -r1.4.2.9 --- squid3/src/win32.cc 17 Aug 2003 19:15:24 -0000 1.4.2.8 +++ squid3/src/win32.cc 21 Jun 2004 21:35:05 -0000 1.4.2.9 @@ -1,6 +1,6 @@ /* - * $Id: win32.cc,v 1.4.2.8 2003/08/17 19:15:24 serassio Exp $ + * $Id: win32.cc,v 1.4.2.9 2004/06/21 21:35:05 serassio Exp $ * * * * * * * * * Legal stuff * * * * * * * * @@ -50,6 +50,7 @@ #endif #include #endif +#include static unsigned int GetOSVersion(); void WIN32_svcstatusupdate(DWORD, DWORD); @@ -906,6 +907,57 @@ #if defined(_SQUID_MSWIN_) static int s_iInitCount = 0; +int WIN32_pipe(int handles[2]) +{ + int new_socket; + fde *F = NULL; + + struct sockaddr_in serv_addr; + int len = sizeof(serv_addr); + u_short handle1_port; + + handles[0] = handles[1] = -1; + + statCounter.syscalls.sock.sockets++; + if ((new_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) + return -1; + + memset((void *) &serv_addr, 0, sizeof(serv_addr)); + serv_addr.sin_family = AF_INET; + serv_addr.sin_port = htons(0); + serv_addr.sin_addr = local_addr; + + if (bind(new_socket, (SOCKADDR *) & serv_addr, len) < 0 || + listen(new_socket, 1) < 0 || getsockname(new_socket, (SOCKADDR *) & serv_addr, &len) < 0 || + (handles[1] = socket(PF_INET, SOCK_STREAM, 0)) < 0) + { + closesocket(new_socket); + return -1; + } + + handle1_port = ntohs(serv_addr.sin_port); + if (connect(handles[1], (SOCKADDR *) & serv_addr, len) < 0 || + (handles[0] = accept(new_socket, (SOCKADDR *) & serv_addr, &len)) < 0) + { + closesocket(handles[1]); + handles[1] = -1; + closesocket(new_socket); + return -1; + } + closesocket(new_socket); + + F = &fd_table[handles[0]]; + F->local_addr = local_addr; + F->local_port = ntohs(serv_addr.sin_port); + + F = &fd_table[handles[1]]; + F->local_addr = local_addr; + xstrncpy(F->ipaddr, inet_ntoa(local_addr), 16); + F->remote_port = handle1_port; + + return 0; +} + int WIN32_getrusage(int who, struct rusage *usage) { #if HAVE_WIN32_PSAPI Index: squid3/src/fs/awin32/aiops.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/fs/awin32/Attic/aiops.cc,v retrieving revision 1.2.18.3 retrieving revision 1.2.18.4 diff -u -r1.2.18.3 -r1.2.18.4 --- squid3/src/fs/awin32/aiops.cc 3 Aug 2003 16:32:02 -0000 1.2.18.3 +++ squid3/src/fs/awin32/aiops.cc 21 Jun 2004 21:35:07 -0000 1.2.18.4 @@ -1,5 +1,5 @@ /* - * $Id: aiops.cc,v 1.2.18.3 2003/08/03 16:32:02 serassio Exp $ + * $Id: aiops.cc,v 1.2.18.4 2004/06/21 21:35:07 serassio Exp $ * * DEBUG: section 43 AIOPS * AUTHOR: Stewart Forster @@ -33,7 +33,6 @@ */ #include "squid.h" -#include "Store.h" #include "squid_windows.h" #include "store_asyncufs.h" @@ -44,6 +43,7 @@ #include #include #include +#include "comm.h" #define RIDICULOUS_LENGTH 4096 @@ -534,6 +534,7 @@ return 1; } + CommIO::NotifyIOCompleted(); Sleep(0); threadp->requests++; } /* while forever */ @@ -1097,6 +1098,7 @@ request = done_requests.head; if (request == NULL && !polled) { + CommIO::ResetNotifications(); squidaio_poll_queues(); polled = 1; request = done_requests.head; Index: squid3/src/fs/awin32/async_io.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/fs/awin32/Attic/async_io.cc,v retrieving revision 1.2.18.2 retrieving revision 1.2.18.3 diff -u -r1.2.18.2 -r1.2.18.3 --- squid3/src/fs/awin32/async_io.cc 3 Aug 2003 16:32:02 -0000 1.2.18.2 +++ squid3/src/fs/awin32/async_io.cc 21 Jun 2004 21:35:07 -0000 1.2.18.3 @@ -1,6 +1,6 @@ /* - * $Id: async_io.cc,v 1.2.18.2 2003/08/03 16:32:02 serassio Exp $ + * $Id: async_io.cc,v 1.2.18.3 2004/06/21 21:35:07 serassio Exp $ * * DEBUG: section 32 Asynchronous Disk I/O * AUTHOR: Pete Bentley @@ -118,7 +118,6 @@ aioStats, 0, 1); initialised = true; - comm_quick_poll_required(); } void Index: squid3/src/fs/awin32/store_asyncufs.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/fs/awin32/Attic/store_asyncufs.h,v retrieving revision 1.2.18.2 retrieving revision 1.2.18.3 diff -u -r1.2.18.2 -r1.2.18.3 --- squid3/src/fs/awin32/store_asyncufs.h 3 Aug 2003 16:32:02 -0000 1.2.18.2 +++ squid3/src/fs/awin32/store_asyncufs.h 21 Jun 2004 21:35:07 -0000 1.2.18.3 @@ -91,7 +91,6 @@ { public: - virtual void deleteSelf() const; void * operator new (size_t); void operator delete (void *); AUFSFile (char const *path, AufsIO *); @@ -167,7 +166,6 @@ AufsIO(); virtual bool shedLoad(); virtual int load(); - virtual void deleteSelf() const; virtual StoreIOState::Pointer createState(SwapDir *SD, StoreEntry *e, STIOCB * callback, void *callback_data) const; virtual DiskFile::Pointer newFile(char const *path); virtual void unlinkFile (char const *); Index: squid3/src/fs/awin32/store_io_aufs.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/fs/awin32/Attic/store_io_aufs.cc,v retrieving revision 1.2.18.2 retrieving revision 1.2.18.3 diff -u -r1.2.18.2 -r1.2.18.3 --- squid3/src/fs/awin32/store_io_aufs.cc 3 Aug 2003 16:32:02 -0000 1.2.18.2 +++ squid3/src/fs/awin32/store_io_aufs.cc 21 Jun 2004 21:35:07 -0000 1.2.18.3 @@ -1,6 +1,6 @@ /* - * $Id: store_io_aufs.cc,v 1.2.18.2 2003/08/03 16:32:02 serassio Exp $ + * $Id: store_io_aufs.cc,v 1.2.18.3 2004/06/21 21:35:07 serassio Exp $ * * DEBUG: section 79 Storage Manager awin32 Interface * AUTHOR: Robert Collins @@ -80,12 +80,6 @@ return loadav; } -void -AufsIO::deleteSelf() const -{ - /* do nothing, we use a single instance */ -} - StoreIOState::Pointer AufsIO::createState(SwapDir *SD, StoreEntry *e, STIOCB * callback, void *callback_data) const { @@ -160,9 +154,6 @@ cbdataReferenceDone (t); } -void -AUFSFile::deleteSelf() const {delete this;} - AUFSFile::AUFSFile (char const *aPath, AufsIO *anIO):fd(-1), errorOccured (false), IO(anIO), inProgressIOs (0) { @@ -212,7 +203,7 @@ void AUFSFile::read(char *buf, off_t offset, size_t size) { - debug(79, 3) ("AUFSFile::read: %p, size %u\n", this, size); + debugs(79, 3, "AUFSFile::read: " << this << ", size " << size); assert (fd > -1); assert (ioRequestor.getRaw()); statCounter.syscalls.disk.reads++;