From: hno <> Date: Tue, 22 Apr 2003 21:06:09 +0000 (+0000) Subject: From Guido: X-Git-Tag: SQUID_3_0_PRE1~239 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1a774556057c249c2f055f3ede972c90bfcf906b;p=thirdparty%2Fsquid.git From Guido: This is the 9th of some splitted native Windows patches grouped by functionality. Native Windows port enhancements: - changed opt_no_daemon to global - now Cygwin can support daemon and Windows service mode in the same binary - added Windows platform info in cache_manager output - missing Makefile.am entry for squid_windows.h - added more Windows service support definitions - added cache.log info when unlinkd is disabled - storeFsDone() is always needed for some fs storage: Coss, Awin32 --- diff --git a/src/Makefile.am b/src/Makefile.am index 929ee4aad0..ecefc3988f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,7 +1,7 @@ # # Makefile for the Squid Object Cache server # -# $Id: Makefile.am,v 1.69 2003/03/15 04:26:07 robertc Exp $ +# $Id: Makefile.am,v 1.70 2003/04/22 15:06:09 hno Exp $ # # Uncomment and customize the following to suit your needs: # @@ -426,7 +426,8 @@ noinst_HEADERS = MemBuf.cci \ Store.cci \ String.cci \ SquidString.h \ - ufscommon.cci + ufscommon.cci \ + squid_windows.h nodist_squid_SOURCES = \ repl_modules.cc \ diff --git a/src/dns_internal.cc b/src/dns_internal.cc index 2b44ea2cd8..0cddc36865 100644 --- a/src/dns_internal.cc +++ b/src/dns_internal.cc @@ -1,6 +1,6 @@ /* - * $Id: dns_internal.cc,v 1.57 2003/03/09 12:29:41 robertc Exp $ + * $Id: dns_internal.cc,v 1.58 2003/04/22 15:06:09 hno Exp $ * * DEBUG: section 78 DNS lookups; interacts with lib/rfc1035.c * AUTHOR: Duane Wessels @@ -43,7 +43,7 @@ */ #ifndef USE_DNSSERVERS #if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_) -#include +#include "squid_windows.h" #endif #ifndef _PATH_RESOLV_CONF #define _PATH_RESOLV_CONF "/etc/resolv.conf" diff --git a/src/globals.h b/src/globals.h index 81efa158c4..1a7b503b90 100644 --- a/src/globals.h +++ b/src/globals.h @@ -1,6 +1,6 @@ /* - * $Id: globals.h,v 1.122 2003/04/20 05:28:58 robertc Exp $ + * $Id: globals.h,v 1.123 2003/04/22 15:06:09 hno Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -177,5 +177,6 @@ extern void *sbrk_start; /* 0 */ extern int ssl_ex_index_server; /* -1 */ extern int ssl_ctx_ex_index_dont_verify_domain; /* -1 */ +extern int opt_no_daemon; /* 0 */ #endif /* SQUID_GLOBALS_H */ diff --git a/src/main.cc b/src/main.cc index 64f6aef280..f935236603 100644 --- a/src/main.cc +++ b/src/main.cc @@ -1,6 +1,6 @@ /* - * $Id: main.cc,v 1.371 2003/04/21 12:52:40 hno Exp $ + * $Id: main.cc,v 1.372 2003/04/22 15:06:10 hno Exp $ * * DEBUG: section 1 Startup and Main Loop * AUTHOR: Harvest Derived @@ -42,11 +42,24 @@ #include "ACLASN.h" #include "ACL.h" +#if USE_WIN32_SERVICE + +#include "squid_windows.h" +#include + +static int opt_install_service = FALSE; +static int opt_remove_service = FALSE; +static int opt_signal_service = FALSE; +static int opt_command_line = FALSE; +extern void WIN32_svcstatusupdate(DWORD, DWORD); +void WINAPI WIN32_svcHandler(DWORD); + +#endif + /* for error reporting from xmalloc and friends */ SQUIDCEXTERN void (*failure_notify) (const char *); static int opt_send_signal = -1; -static int opt_no_daemon = 0; static int opt_parse_cfg_only = 0; static int icpPortNumOverride = 1; /* Want to detect "-u 0" */ static int configured_once = 0; @@ -282,6 +295,12 @@ mainParseOptions(int argc, char *argv[]) case 'v': printf("Squid Cache: Version %s\nconfigure options: %s\n", version_string, SQUID_CONFIGURE_OPTIONS); +#if USE_WIN32_SERVICE + + printf("Compiled as Windows System Service.\n"); + +#endif + exit(0); /* NOTREACHED */ @@ -1269,9 +1288,9 @@ SquidShutdown(void *unused) #endif storeDirSync(); /* Flush log close */ + storeFsDone(); #if PURIFY || XMALLOC_TRACE - storeFsDone(); configFreeMemory(); storeFreeMemory(); /*stmemFreeMemory(); */ diff --git a/src/stat.cc b/src/stat.cc index f473cbb39f..b8945481a2 100644 --- a/src/stat.cc +++ b/src/stat.cc @@ -1,6 +1,6 @@ /* - * $Id: stat.cc,v 1.372 2003/03/15 04:17:41 robertc Exp $ + * $Id: stat.cc,v 1.373 2003/04/22 15:06:10 hno Exp $ * * DEBUG: section 18 Cache Manager Statistics * AUTHOR: Harvest Derived @@ -455,6 +455,17 @@ info_get(StoreEntry * sentry) storeAppendPrintf(sentry, "Squid Object Cache: Version %s\n", version_string); +#if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_) + + if (WIN32_run_mode == _WIN_SQUID_RUN_MODE_SERVICE) { + storeAppendPrintf(sentry,"\nRunning as %s Windows System Service on %s\n", + WIN32_Service_name, WIN32_OS_string); + storeAppendPrintf(sentry,"Service command line is: %s\n", WIN32_Service_Command_Line); + } else + storeAppendPrintf(sentry,"Running on %s\n",WIN32_OS_string); + +#endif + storeAppendPrintf(sentry, "Start Time:\t%s\n", mkrfc1123(squid_start.tv_sec)); @@ -671,7 +682,6 @@ info_get(StoreEntry * sentry) statMemoryAccounted() >> 10); #endif - { MemPoolGlobalStats mp_stats; memPoolGetGlobalStats(&mp_stats); diff --git a/src/win32.cc b/src/win32.cc index bc0599bb54..51a9c5bab1 100644 --- a/src/win32.cc +++ b/src/win32.cc @@ -1,6 +1,6 @@ /* - * $Id: win32.cc,v 1.8 2003/04/21 12:54:10 hno Exp $ + * $Id: win32.cc,v 1.9 2003/04/22 15:06:11 hno Exp $ * * * * * * * * * Legal stuff * * * * * * * * @@ -40,21 +40,19 @@ #include "squid.h" -/* This code compiles only on Cygwin & Windows NT Port */ -#if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_) #include "squid_windows.h" static unsigned int GetOSVersion(); void WIN32_svcstatusupdate(DWORD, DWORD); void WINAPI WIN32_svcHandler(DWORD); -#ifdef USE_WIN32_SERVICE +#if USE_WIN32_SERVICE static int WIN32_StoreKey(const char *, DWORD, unsigned char *, int); static int WIN32_create_key(void); static void WIN32_build_argv (char *); #endif extern "C" void WINAPI SquidMain(DWORD, char **); -#ifdef USE_WIN32_SERVICE +#if USE_WIN32_SERVICE static SERVICE_STATUS svcStatus; static SERVICE_STATUS_HANDLE svcHandle; static int WIN32_argc; @@ -80,7 +78,7 @@ typedef BOOL (WINAPI * PFChangeServiceConfig2) (SC_HANDLE, DWORD, LPVOID); #else #define CHANGESERVICECONFIG2 "ChangeServiceConfig2A" #endif -#ifdef USE_WIN32_SERVICE +#if USE_WIN32_SERVICE static SC_ACTION Squid_SCAction[] = { { SC_ACTION_RESTART, 60000 } }; static char Squid_ServiceDescriptionString[] = SOFTWARENAME " " VERSION " WWW Proxy Server"; static SERVICE_DESCRIPTION Squid_ServiceDescription = { Squid_ServiceDescriptionString }; @@ -100,7 +98,7 @@ static char *keys[] = { /* LOCAL FUNCTIONS */ /* ====================================================================== */ -#ifdef USE_WIN32_SERVICE +#if USE_WIN32_SERVICE static int WIN32_create_key(void) { @@ -308,7 +306,7 @@ GetOSVersion() return _WIN_OS_UNKNOWN; } -#ifdef USE_WIN32_SERVICE +#if USE_WIN32_SERVICE /* Build argv, argc from string passed from Windows. */ static void WIN32_build_argv(char *cmd) { @@ -363,7 +361,7 @@ static void WIN32_build_argv(char *cmd) void WIN32_Abort(int sig) { -#ifdef USE_WIN32_SERVICE +#if USE_WIN32_SERVICE svcStatus.dwWin32ExitCode = ERROR_SERVICE_SPECIFIC_ERROR; svcStatus.dwServiceSpecificExitCode = 1; #endif @@ -375,7 +373,7 @@ WIN32_Abort(int sig) void WIN32_Exit() { -#ifdef USE_WIN32_SERVICE +#if USE_WIN32_SERVICE if (!Squid_Aborting) { svcStatus.dwCurrentState = SERVICE_STOPPED; @@ -387,7 +385,7 @@ WIN32_Exit() _exit(0); } -#ifdef USE_WIN32_SERVICE +#if USE_WIN32_SERVICE int WIN32_Subsystem_Init(int * argc, char *** argv) #else int @@ -402,7 +400,7 @@ WIN32_Subsystem_Init() if (atexit(WIN32_Exit) != 0) return 1; -#ifdef USE_WIN32_SERVICE +#if USE_WIN32_SERVICE if (WIN32_run_mode == _WIN_SQUID_RUN_MODE_SERVICE) { @@ -488,7 +486,7 @@ WIN32_Subsystem_Init() return 0; } -#ifdef USE_WIN32_SERVICE +#if USE_WIN32_SERVICE void WIN32_svcstatusupdate(DWORD svcstate, DWORD WaitHint) { @@ -833,6 +831,7 @@ int main(int argc, char **argv) if ((argc == 2) && strstr(argv[1], _WIN_SQUID_SERVICE_OPTION)) { WIN32_run_mode = _WIN_SQUID_RUN_MODE_SERVICE; + opt_no_daemon = 1; if (!(c=strchr(argv[1],':'))) { fprintf(stderr, "Bad Service Parameter: %s\n", argv[1]); @@ -859,6 +858,4 @@ int main(int argc, char **argv) #endif /* USE_WIN32_SERVICE */ -#endif /* defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_) */ - #endif /* WIN32_C */