diff options
author | Andrew Morrow <acm@mongodb.com> | 2016-03-11 14:34:47 -0500 |
---|---|---|
committer | Andrew Morrow <acm@mongodb.com> | 2016-03-21 22:55:32 -0400 |
commit | 4d6dd3b4359dc3cc8145beb10e54f84353689351 (patch) | |
tree | d2ca8c518ef2064854d5e9c1584fd89eab31d9e6 /src/mongo/util/quick_exit.cpp | |
parent | 20ca6518797b67206d1f23d097c61c78a3ad8810 (diff) | |
download | mongo-4d6dd3b4359dc3cc8145beb10e54f84353689351.tar.gz |
SERVER-23103 Unify exit handling
Diffstat (limited to 'src/mongo/util/quick_exit.cpp')
-rw-r--r-- | src/mongo/util/quick_exit.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/mongo/util/quick_exit.cpp b/src/mongo/util/quick_exit.cpp index d9e35e13528..e53c99420a4 100644 --- a/src/mongo/util/quick_exit.cpp +++ b/src/mongo/util/quick_exit.cpp @@ -39,6 +39,9 @@ // This will probably get us _exit on non-unistd platforms like Windows. #include <cstdlib> +// NOTE: Header only dependencies are OK in this library. +#include "mongo/stdx/mutex.h" + #if !defined(__has_feature) #define __has_feature(x) 0 #endif @@ -65,7 +68,16 @@ extern "C" void __gcov_flush(); namespace mongo { +namespace { +stdx::mutex* const quickExitMutex = new stdx::mutex; +} // namespace + void quickExit(int code) { + // Ensure that only one thread invokes the last rites here. No + // RAII here - we never want to unlock this. + if (quickExitMutex) + quickExitMutex->lock(); + #ifdef MONGO_GCOV __gcov_flush(); #endif |