]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
From Guido:
authorhno <>
Tue, 22 Apr 2003 21:06:09 +0000 (21:06 +0000)
committerhno <>
Tue, 22 Apr 2003 21:06:09 +0000 (21:06 +0000)
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

src/Makefile.am
src/dns_internal.cc
src/globals.h
src/main.cc
src/stat.cc
src/win32.cc

index 929ee4aad0a4c1d72a3415284af663914c60a387..ecefc3988ff3d4353bab535e3d2924b8322b63da 100644 (file)
@@ -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 \
index 2b44ea2cd82cc520aed525f6e78154b436667c6c..0cddc36865442a67aec191768f2640eca5f1c2f8 100644 (file)
@@ -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 <windows.h>
+#include "squid_windows.h"
 #endif
 #ifndef _PATH_RESOLV_CONF
 #define _PATH_RESOLV_CONF "/etc/resolv.conf"
index 81efa158c457086d038fdd8255f02aae2f193728..1a7b503b906d5f9beea57ec66945dfa870bbfeae 100644 (file)
@@ -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 */
index 64f6aef2805e53acaeffc06531c730a956e75797..f935236603bfee5db5e62061a6311cce1ba3d24d 100644 (file)
@@ -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
 #include "ACLASN.h"
 #include "ACL.h"
 
+#if USE_WIN32_SERVICE
+
+#include "squid_windows.h"
+#include <process.h>
+
+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(); */
index f473cbb39f9f6a81d50cb63838bd8d88158f0953..b8945481a279195d1dc4d667dca84cf60bafbdbf 100644 (file)
@@ -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);
index bc0599bb54417197401554b2612472d681dc4929..51a9c5bab1b3dcaec93bbec36c66166b9b7376fc 100644 (file)
@@ -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 * * * * * * *
  *
 
 #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 */