From 6bd41f28ef8afb43bffaca4af7048e49be3528e8 Mon Sep 17 00:00:00 2001 From: Testo Date: Wed, 9 Mar 2011 23:00:53 +0800 Subject: [PATCH] SERVER-2719: clean up the log file when Windows shuts down --- util/ntservice.cpp | 13 ++++++++++++- 1 files changed, 12 insertions(+), 1 deletions(-) diff --git a/util/ntservice.cpp b/util/ntservice.cpp index ccf2981..ce94c38 100644 --- a/util/ntservice.cpp +++ b/util/ntservice.cpp @@ -314,7 +314,17 @@ namespace mongo { ssStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS; ssStatus.dwServiceSpecificExitCode = 0; - ssStatus.dwControlsAccepted = reportState == SERVICE_START_PENDING ? 0 : SERVICE_ACCEPT_STOP; + switch(reportState) { + case SERVICE_START_PENDING: + case SERVICE_STOP_PENDING: + case SERVICE_STOPPED: + ssStatus.dwControlsAccepted = 0; + break; + default: + ssStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN; + break; + } + ssStatus.dwCurrentState = reportState; ssStatus.dwWin32ExitCode = NO_ERROR; ssStatus.dwWaitHint = waitHint; @@ -340,6 +350,7 @@ namespace mongo { switch ( ctrlCode ) { case SERVICE_CONTROL_STOP: case SERVICE_CONTROL_SHUTDOWN: + reportStatus( SERVICE_STOP_PENDING ); shutdownServer(); reportStatus( SERVICE_STOPPED ); return; -- 1.7.3.1.msysgit.0