--------------------- PatchSet 5435 Date: 2002/10/22 20:21:19 Author: serassio Branch: cygwin-svc Tag: (none) Log: Merged latest win32 changes from nt branch Members: configure.in:1.8.2.10.2.30->1.8.2.10.2.31 src/main.c:1.12.2.12.2.19->1.12.2.12.2.20 src/win32.c:1.1.50.6.2.23->1.1.50.6.2.24 Index: squid/configure.in =================================================================== RCS file: /cvsroot/squid-sf//squid/configure.in,v retrieving revision 1.8.2.10.2.30 retrieving revision 1.8.2.10.2.31 diff -u -r1.8.2.10.2.30 -r1.8.2.10.2.31 --- squid/configure.in 22 Oct 2002 19:57:31 -0000 1.8.2.10.2.30 +++ squid/configure.in 22 Oct 2002 20:21:19 -0000 1.8.2.10.2.31 @@ -3,7 +3,7 @@ dnl dnl Duane Wessels, wessels@nlanr.net, February 1996 (autoconf v2.9) dnl -dnl $Id: configure.in,v 1.8.2.10.2.30 2002/10/22 19:57:31 serassio Exp $ +dnl $Id: configure.in,v 1.8.2.10.2.31 2002/10/22 20:21:19 serassio Exp $ dnl dnl dnl @@ -13,7 +13,7 @@ AC_CONFIG_AUX_DIR(cfgaux) AM_INIT_AUTOMAKE(squid, 2.6-DEVEL) AM_CONFIG_HEADER(include/autoconf.h) -AC_REVISION($Revision: 1.8.2.10.2.30 $)dnl +AC_REVISION($Revision: 1.8.2.10.2.31 $)dnl AC_PREFIX_DEFAULT(/usr/local/squid) AM_MAINTAINER_MODE @@ -891,7 +891,7 @@ Works only on Windows NT and Windows 2000 Platforms.], [ if test "$enableval" = "yes" ; then echo "Enabling WIN32 run service mode" - AC_DEFINE(USE_WIN32_SERVICE) + AC_DEFINE(USE_WIN32_SERVICE,1,[Define Windows NT & Windows 2000 run service mode]) fi ]) Index: squid/src/main.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/main.c,v retrieving revision 1.12.2.12.2.19 retrieving revision 1.12.2.12.2.20 diff -u -r1.12.2.12.2.19 -r1.12.2.12.2.20 --- squid/src/main.c 22 Oct 2002 19:57:34 -0000 1.12.2.12.2.19 +++ squid/src/main.c 22 Oct 2002 20:21:20 -0000 1.12.2.12.2.20 @@ -1,6 +1,6 @@ /* - * $Id: main.c,v 1.12.2.12.2.19 2002/10/22 19:57:34 serassio Exp $ + * $Id: main.c,v 1.12.2.12.2.20 2002/10/22 20:21:20 serassio Exp $ * * DEBUG: section 1 Startup and Main Loop * AUTHOR: Harvest Derived @@ -42,7 +42,7 @@ static int opt_remove_service = FALSE; static int opt_signal_service = FALSE; static int opt_command_line = FALSE; -extern void WIN32_svcstatusupdate(DWORD); +extern void WIN32_svcstatusupdate(DWORD, DWORD); void WINAPI WIN32_svcHandler(DWORD); #endif @@ -691,7 +691,7 @@ failure_notify = fatal_dump; #if defined(USE_WIN32_SERVICE) && (defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_)) - WIN32_svcstatusupdate(SERVICE_START_PENDING); + WIN32_svcstatusupdate(SERVICE_START_PENDING, 10000); #endif mainParseOptions(argc, argv); @@ -788,12 +788,12 @@ fd_open(2, FD_LOG, "stderr"); } #if defined(USE_WIN32_SERVICE) && (defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_)) - WIN32_svcstatusupdate(SERVICE_START_PENDING); + WIN32_svcstatusupdate(SERVICE_START_PENDING, 10000); #endif mainInitialize(); #if defined(USE_WIN32_SERVICE) && (defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_)) - WIN32_svcstatusupdate(SERVICE_RUNNING); + WIN32_svcstatusupdate(SERVICE_RUNNING, 0); #endif /* main loop */ @@ -812,10 +812,10 @@ (int) wait); do_shutdown = 0; shutting_down = 1; - serverConnectionsClose(); #if defined(USE_WIN32_SERVICE) && (defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_)) - WIN32_svcstatusupdate(SERVICE_STOP_PENDING); + WIN32_svcstatusupdate(SERVICE_STOP_PENDING, (wait + 1) * 1000); #endif + serverConnectionsClose(); #if USE_DNSSERVERS dnsShutdown(); #else @@ -868,7 +868,7 @@ WIN32_sendSignal(opt_send_signal); else { #endif -#ifdef _SQUID_MSWIN_ +#if defined(_SQUID_MSWIN_) && defined(USE_WIN32_SERVICE) fprintf(stderr, "%s: ERROR: Could not send ", appname); fprintf(stderr, "signal to Squid Service:\n"); fprintf(stderr, "missing -n command line switch.\n"); @@ -1053,6 +1053,9 @@ static void SquidShutdown(void *unused) { +#if defined(USE_WIN32_SERVICE) && (defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_)) + WIN32_svcstatusupdate(SERVICE_STOP_PENDING, 10000); +#endif debug(1, 1) ("Shutting down...\n"); if (Config.pidFilename && strcmp(Config.pidFilename, "none")) { enter_suid(); @@ -1075,6 +1078,9 @@ #if USE_UNLINKD unlinkdClose(); #endif +#if defined(USE_WIN32_SERVICE) && (defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_)) + WIN32_svcstatusupdate(SERVICE_STOP_PENDING, 10000); +#endif storeDirSync(); /* Flush pending object writes/unlinks */ storeDirWriteCleanLogs(0); PrintRusage(); Index: squid/src/win32.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/win32.c,v retrieving revision 1.1.50.6.2.23 retrieving revision 1.1.50.6.2.24 diff -u -r1.1.50.6.2.23 -r1.1.50.6.2.24 --- squid/src/win32.c 24 Aug 2002 08:14:28 -0000 1.1.50.6.2.23 +++ squid/src/win32.c 22 Oct 2002 20:21:20 -0000 1.1.50.6.2.24 @@ -51,7 +51,7 @@ #endif static unsigned int GetOSVersion(); -void WIN32_svcstatusupdate(DWORD); +void WIN32_svcstatusupdate(DWORD, DWORD); void WINAPI WIN32_svcHandler(DWORD); static int WIN32_StoreKey(const char *, DWORD, unsigned char *, int); static int WIN32_create_key(void); @@ -71,6 +71,7 @@ static int WIN32_argc; static char ** WIN32_argv; static char * WIN32_module_name; +static int Squid_Aborting = 0; #define VENDOR "GNU" #if defined(_SQUID_MSWIN_) @@ -90,7 +91,7 @@ #endif static SC_ACTION Squid_SCAction[] = { { SC_ACTION_RESTART, 60000 } }; static SERVICE_DESCRIPTION Squid_ServiceDescription = { SOFTWARENAME " " VERSION " WWW Proxy Server" }; -static SERVICE_FAILURE_ACTIONS Squid_ServiceFailureActions = { 0, NULL, NULL, 1, Squid_SCAction }; +static SERVICE_FAILURE_ACTIONS Squid_ServiceFailureActions = { INFINITE, NULL, NULL, 1, Squid_SCAction }; static char REGKEY[256]="SOFTWARE\\"VENDOR"\\"SOFTWARENAME"\\"WIN32_VERSION"\\"; static char *keys[] = { "SOFTWARE", /* key[0] */ @@ -319,6 +320,7 @@ svcStatus.dwWin32ExitCode = ERROR_SERVICE_SPECIFIC_ERROR; svcStatus.dwServiceSpecificExitCode = 1; #endif + Squid_Aborting = 1; WIN32_Exit(); } @@ -329,8 +331,10 @@ Win32SockCleanup(); #endif #ifdef USE_WIN32_SERVICE - svcStatus.dwCurrentState = SERVICE_STOPPED; - SetServiceStatus(svcHandle, &svcStatus); + if (!Squid_Aborting) { + svcStatus.dwCurrentState = SERVICE_STOPPED; + SetServiceStatus(svcHandle, &svcStatus); + } #endif #ifdef _SQUID_MSWIN_ if (dbg_mutex) @@ -423,10 +427,11 @@ #ifdef USE_WIN32_SERVICE void -WIN32_svcstatusupdate(DWORD svcstate) +WIN32_svcstatusupdate(DWORD svcstate, DWORD WaitHint) { if (WIN32_run_mode == _WIN_SQUID_RUN_MODE_SERVICE) { svcStatus.dwCheckPoint++; + svcStatus.dwWaitHint = WaitHint; svcStatus.dwCurrentState = svcstate; SetServiceStatus(svcHandle, &svcStatus); } @@ -749,13 +754,13 @@ PROCESS_VM_READ, FALSE, GetCurrentProcessId()); { - /* Microsoft Visual C++ doesn't have getrusage function, */ + /* Microsoft CRT 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 / 10); - LONGLONG tKernel64 = (*(LONGLONG *)&ftKernel / 10); + int64_t tUser64 = (*(int64_t *)&ftUser / 10); + int64_t tKernel64 = (*(int64_t *)&ftKernel / 10); usage->ru_utime.tv_sec =(long)(tUser64 / 1000000); usage->ru_stime.tv_sec =(long)(tKernel64 / 1000000); usage->ru_utime.tv_usec =(long)(tUser64 % 1000000);