diff options
author | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2014-07-17 13:39:21 -0400 |
---|---|---|
committer | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2014-07-18 15:00:39 -0400 |
commit | 848999f1527e8390d4d76f9fad0860218b73be4d (patch) | |
tree | 7914a7b10c071b2d054bb40237156de9f5bdb8d1 | |
parent | 7dbc49a56d010ceaf6d9b57f373863763fe10280 (diff) | |
download | mongo-848999f1527e8390d4d76f9fad0860218b73be4d.tar.gz |
SERVER-14475 Cleanup the shutdown code and indicate shutdown earlier
-rw-r--r-- | src/mongo/db/instance.cpp | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/src/mongo/db/instance.cpp b/src/mongo/db/instance.cpp index 41ff61160dd..da48a427e23 100644 --- a/src/mongo/db/instance.cpp +++ b/src/mongo/db/instance.cpp @@ -997,11 +997,10 @@ namespace { } - mongo::mutex exitMutex("exit"); - AtomicUInt numExitCalls = 0; + static AtomicUInt32 shutdownInProgress(0); bool inShutdown() { - return numExitCalls > 0; + return shutdownInProgress.load() != 0; } static void shutdownServer(OperationContext* txn) { @@ -1022,6 +1021,8 @@ namespace { } void exitCleanly( ExitCode code ) { + shutdownInProgress.store(1); + getGlobalEnvironment()->setKillAllOperations(); repl::getGlobalReplicationCoordinator()->shutdown(); @@ -1051,22 +1052,10 @@ namespace { dbexit( code ); } - /* not using log() herein in case we are already locked */ NOINLINE_DECL void dbexit( ExitCode rc, const char *why ) { flushForGcov(); audit::logShutdown(currentClient.get()); - { - scoped_lock lk( exitMutex ); - if ( numExitCalls++ > 0 ) { - if ( numExitCalls > 5 ) { - // this means something horrible has happened - ::_exit( rc ); - } - log() << "dbexit: " << why << "; exiting immediately"; - ::_exit( rc ); - } - } log() << "dbexit: " << why; @@ -1085,7 +1074,7 @@ namespace { return; } #endif - log() << "dbexit: really exiting now"; + ::_exit(rc); } |