------------------------------------------------------------ revno: 13625 revision-id: squid3@treenet.co.nz-20141003133452-0ccjhf11128hcubk parent: squid3@treenet.co.nz-20141003114529-nz16h42tmh9lqyj8 committer: Amos Jeffries branch nick: trunk timestamp: Fri 2014-10-03 06:34:52 -0700 message: Windows: remove alternative main() As a side effect this causes Windows builds to use the wrapper function for handling exceptions. ------------------------------------------------------------ # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: squid3@treenet.co.nz-20141003133452-0ccjhf11128hcubk # target_branch: http://bzr.squid-cache.org/bzr/squid3/trunk/ # testament_sha1: 5e662f16fb543e52ddf5a2a791900f3dede14723 # timestamp: 2014-10-06 17:34:58 +0000 # source_branch: http://bzr.squid-cache.org/bzr/squid3/trunk # base_revision_id: squid3@treenet.co.nz-20141003114529-\ # nz16h42tmh9lqyj8 # # Begin patch === modified file 'src/WinSvc.cc' --- src/WinSvc.cc 2014-10-03 11:45:29 +0000 +++ src/WinSvc.cc 2014-10-03 13:34:52 +0000 @@ -891,7 +891,7 @@ CloseServiceHandle(schSCManager); } -int main(int argc, char **argv) +int WIN32_StartService(int argc, char **argv) { SERVICE_TABLE_ENTRY DispatchTable[] = { {NULL, SquidWinSvcMain}, @@ -900,35 +900,26 @@ char *c; char stderr_path[256]; - SetErrorMode(SEM_NOGPFAULTERRORBOX); - if ((argc == 2) && strstr(argv[1], _WIN_SQUID_SERVICE_OPTION)) { - strcpy(stderr_path, argv[0]); - strcat(stderr_path,".log"); - freopen(stderr_path, "w", stderr); - setmode(fileno(stderr), O_TEXT); - WIN32_run_mode = _WIN_SQUID_RUN_MODE_SERVICE; - - if (!(c=strchr(argv[1],':'))) { - fprintf(stderr, "Bad Service Parameter: %s\n", argv[1]); - return 1; - } - - service_name = SBuf(c+1); - const char *service = service_name.c_str(); - DispatchTable[0].lpServiceName = const_cast(service); - strcat(REGKEY, service); - keys[4] = const_cast(service); - - if (!StartServiceCtrlDispatcher(DispatchTable)) { - fprintf(stderr, "StartServiceCtrlDispatcher error = %ld\n", - GetLastError()); - return 1; - } - } else { - WIN32_run_mode = _WIN_SQUID_RUN_MODE_INTERACTIVE; - opt_no_daemon = 1; - - return SquidMain(argc, argv); + strcpy(stderr_path, argv[0]); + strcat(stderr_path,".log"); + freopen(stderr_path, "w", stderr); + setmode(fileno(stderr), O_TEXT); + WIN32_run_mode = _WIN_SQUID_RUN_MODE_SERVICE; + + if (!(c=strchr(argv[1],':'))) { + fprintf(stderr, "Bad Service Parameter: %s\n", argv[1]); + return 1; + } + + service_name = SBuf(c+1); + const char *service = service_name.c_str(); + DispatchTable[0].lpServiceName = const_cast(service); + strcat(REGKEY, service); + keys[4] = const_cast(service); + + if (!StartServiceCtrlDispatcher(DispatchTable)) { + fprintf(stderr, "StartServiceCtrlDispatcher error = %ld\n", GetLastError()); + return 1; } return 0; === modified file 'src/WinSvc.h' --- src/WinSvc.h 2014-09-13 13:59:43 +0000 +++ src/WinSvc.h 2014-10-03 13:34:52 +0000 @@ -10,12 +10,12 @@ #define WINSVC_H_ #if _SQUID_WINDOWS_ +int WIN32_StartService(int, char **); int WIN32_Subsystem_Init(int *, char ***); void WIN32_sendSignal(int); void WIN32_SetServiceCommandLine(void); void WIN32_InstallService(void); void WIN32_RemoveService(void); -int SquidMain(int, char **); #else /* _SQUID_WINDOWS_ */ inline int WIN32_Subsystem_Init(int *foo, char ***bar) {return 0; } /* NOP */ inline void WIN32_sendSignal(int foo) { return; } /* NOP */ === modified file 'src/main.cc' --- src/main.cc 2014-09-30 13:11:58 +0000 +++ src/main.cc 2014-10-03 13:34:52 +0000 @@ -1209,19 +1209,29 @@ static int SquidMainSafe(int argc, char **argv); #if USE_WIN32_SERVICE -/* When USE_WIN32_SERVICE is defined, the main function is placed in win32.cc */ +/* Entry point for Windows services */ extern "C" void WINAPI SquidWinSvcMain(int argc, char **argv) { SquidMainSafe(argc, argv); } -#else +#endif + int main(int argc, char **argv) { +#if USE_WIN32_SERVICE + SetErrorMode(SEM_NOGPFAULTERRORBOX); + if ((argc == 2) && strstr(argv[1], _WIN_SQUID_SERVICE_OPTION)) + return WIN32_StartService(argc, argv); + else { + WIN32_run_mode = _WIN_SQUID_RUN_MODE_INTERACTIVE; + opt_no_daemon = 1; + } +#endif + return SquidMainSafe(argc, argv); } -#endif static int SquidMainSafe(int argc, char **argv)