diff options
author | Tad Marshall <tad@10gen.com> | 2012-08-17 05:48:08 -0400 |
---|---|---|
committer | Tad Marshall <tad@10gen.com> | 2012-08-17 05:48:08 -0400 |
commit | bd761d51930a8481a14664c98ae1219c858cdd02 (patch) | |
tree | 4e99d2f14373650799dd033ae29774d2fea4f1c3 /src/mongo/util/ntservice.cpp | |
parent | a30fbf1c35b266c608e50a48d68d4a7a147015e8 (diff) | |
download | mongo-bd761d51930a8481a14664c98ae1219c858cdd02.tar.gz |
Revert "SERVER-6771 don't exit until SCM is done with us"
This reverts commit a30fbf1c35b266c608e50a48d68d4a7a147015e8.
This change appears to have broken clean shutdown in many cases
(presumably because I skip a call to exitCleanly if a shutdown is
already in progress).
Diffstat (limited to 'src/mongo/util/ntservice.cpp')
-rw-r--r-- | src/mongo/util/ntservice.cpp | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/src/mongo/util/ntservice.cpp b/src/mongo/util/ntservice.cpp index 0cb75e1bb74..92dfa7d8990 100644 --- a/src/mongo/util/ntservice.cpp +++ b/src/mongo/util/ntservice.cpp @@ -30,16 +30,15 @@ namespace mongo { SERVICE_STATUS_HANDLE ServiceController::_statusHandle = NULL; wstring ServiceController::_serviceName; + ServiceCallback ServiceController::_serviceCallback = NULL; ServiceController::ServiceController() {} // defined in db/db.cpp for mongod.exe and in s/server.cpp for mongos.exe - extern void initService(void); + extern bool initService(); - // handle the logic around running as a service. only returns if we should run normally; - // exits directly when installing or removing a service and after running as a service when - // we are started with --service. - void serviceParamsCheck( + // returns true if the service is started. + bool serviceParamsCheck( boost::program_options::variables_map& params, const std::string dbpath, const ntServiceDefaultStrings& defaultStrings, @@ -164,11 +163,12 @@ namespace mongo { ::_exit( EXIT_CLEAN ); } else if ( startService ) { - if ( !ServiceController::startService( windowsServiceName ) ) { + if ( !ServiceController::startService( windowsServiceName , mongo::initService ) ) { ::_exit( EXIT_NTSERVICE_ERROR ); } - dbexit( EXIT_CLEAN ); + return true; } + return false; } bool ServiceController::installService( @@ -412,11 +412,12 @@ namespace mongo { return serviceRemoved; } - bool ServiceController::startService( const wstring& serviceName ) { + bool ServiceController::startService( const wstring& serviceName, ServiceCallback startService ) { _serviceName = serviceName; + _serviceCallback = startService; SERVICE_TABLE_ENTRY dispTable[] = { - { (LPTSTR)serviceName.c_str(), ServiceController::initService }, + { (LPTSTR)serviceName.c_str(), (LPSERVICE_MAIN_FUNCTION)ServiceController::initService }, { NULL, NULL } }; @@ -461,14 +462,17 @@ namespace mongo { return; reportStatus( SERVICE_START_PENDING, 1000 ); - mongo::initService(); + + _serviceCallback(); + reportStatus( SERVICE_STOPPED ); + ::_exit( EXIT_CLEAN ); } static void serviceShutdown( const char* controlCodeName ) { Client::initThread( "serviceShutdown" ); log() << "got " << controlCodeName << " request from Windows Service Control Manager, " << ( inShutdown() ? "already in shutdown" : "will terminate after current cmd ends" ) << endl; - ServiceController::reportStatus( SERVICE_STOP_PENDING, 5000 ); + ServiceController::reportStatus( SERVICE_STOP_PENDING ); if ( ! inShutdown() ) { // TODO: SERVER-5703, separate the "cleanup for shutdown" functionality from // the "terminate process" functionality in exitCleanly. |