--------------------- PatchSet 2744 Date: 2001/08/12 16:05:13 Author: serassio Branch: cygwin-svc Tag: (none) Log: Added WIN32 abort() service hook Members: src/main.c:1.12.2.12.2.3->1.12.2.12.2.4 src/protos.h:1.9.2.11.2.3->1.9.2.11.2.4 src/win32.c:1.1.50.6.2.3->1.1.50.6.2.4 Index: squid/src/main.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/main.c,v retrieving revision 1.12.2.12.2.3 retrieving revision 1.12.2.12.2.4 diff -u -r1.12.2.12.2.3 -r1.12.2.12.2.4 --- squid/src/main.c 12 Aug 2001 15:03:16 -0000 1.12.2.12.2.3 +++ squid/src/main.c 12 Aug 2001 16:05:13 -0000 1.12.2.12.2.4 @@ -1,6 +1,6 @@ /* - * $Id: main.c,v 1.12.2.12.2.3 2001/08/12 15:03:16 serassio Exp $ + * $Id: main.c,v 1.12.2.12.2.4 2001/08/12 16:05:13 serassio Exp $ * * DEBUG: section 1 Startup and Main Loop * AUTHOR: Harvest Derived @@ -640,7 +640,6 @@ #ifdef USE_WIN32_SERVICE if (WIN32_Subsystem_Init()) return; -/* opt_no_daemon=(WIN32_run_mode == _WIN_SQUID_RUN_MODE_SERVICE) ? 0 : 1; */ #else { int WIN32_init_err; Index: squid/src/protos.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/protos.h,v retrieving revision 1.9.2.11.2.3 retrieving revision 1.9.2.11.2.4 diff -u -r1.9.2.11.2.3 -r1.9.2.11.2.4 --- squid/src/protos.h 12 Aug 2001 15:03:16 -0000 1.9.2.11.2.3 +++ squid/src/protos.h 12 Aug 2001 16:05:13 -0000 1.9.2.11.2.4 @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.9.2.11.2.3 2001/08/12 15:03:16 serassio Exp $ + * $Id: protos.h,v 1.9.2.11.2.4 2001/08/12 16:05:13 serassio Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -1312,14 +1312,10 @@ /* CygWin & Windows NT Port */ /* win32.c */ #if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_) -<<<<<<< protos.h -extern int WIN32_Subsystem_Init(); +extern int WIN32_Subsystem_Init(void); extern void WIN32_sendSignal(int); -extern void WIN32_Exit(int); +extern void WIN32_Abort(int); +extern void WIN32_Exit(void); extern void WIN32_InstallService(void); extern void WIN32_RemoveService(void); -======= -extern int WIN32_Subsystem_Init(void); -extern void WIN32_Exit(void); ->>>>>>> 1.9.2.13 #endif Index: squid/src/win32.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/win32.c,v retrieving revision 1.1.50.6.2.3 retrieving revision 1.1.50.6.2.4 diff -u -r1.1.50.6.2.3 -r1.1.50.6.2.4 --- squid/src/win32.c 12 Aug 2001 15:03:16 -0000 1.1.50.6.2.3 +++ squid/src/win32.c 12 Aug 2001 16:05:13 -0000 1.1.50.6.2.4 @@ -221,16 +221,22 @@ /* ====================================================================== */ void +WIN32_Abort(int sig) +{ +#ifdef USE_WIN32_SERVICE + svcStatus.dwWin32ExitCode = ERROR_SERVICE_SPECIFIC_ERROR; + svcStatus.dwServiceSpecificExitCode = 1; +#endif + WIN32_Exit(); +} + +void WIN32_Exit() { #ifdef _SQUID_MSWIN_ Win32SockCleanup(); #endif #ifdef USE_WIN32_SERVICE - if (ExitStatus) { - svcStatus.dwWin32ExitCode = ERROR_SERVICE_SPECIFIC_ERROR; - svcStatus.dwServiceSpecificExitCode = 1; - } svcStatus.dwCurrentState = SERVICE_STOPPED; SetServiceStatus(svcHandle, &svcStatus); #endif @@ -241,10 +247,14 @@ WIN32_Subsystem_Init() { WIN32_OS_version = GetOSVersion(); + if (atexit(WIN32_Exit) != 0) + return 1; #ifdef USE_WIN32_SERVICE if (WIN32_run_mode == _WIN_SQUID_RUN_MODE_SERVICE) { char path[512]; HKEY hndKey; + if (signal(SIGABRT, WIN32_Abort) == SIG_ERR) + return 1; /* Register the service Handler function */ svcHandle = RegisterServiceCtrlHandler(WIN32_Service_name, @@ -289,8 +299,6 @@ #ifdef _SQUID_MSWIN_ Win32SockInit(); #endif - if (atexit(WIN32_Exit) != 0) - return 1; return 0; }