diff options
author | Mathias Stearn <mathias@10gen.com> | 2016-01-12 17:31:41 -0500 |
---|---|---|
committer | Mathias Stearn <redbeard0531@gmail.com> | 2016-01-18 13:33:40 -0500 |
commit | ed3471a81dec950f863ca6f9c73ea5e90f866875 (patch) | |
tree | 39b37389e35b5d05420affd159a48ccd120fca84 /src | |
parent | 4946e2dd15dc97d0c884d04f63a8f9470839786f (diff) | |
download | mongo-ed3471a81dec950f863ca6f9c73ea5e90f866875.tar.gz |
SERVER-22160 Make statics for background.cpp immortal
This resolves static-initialization-order-fiasco problems with
cursor_manager.cpp.
(cherry picked from commit d9e0595751bb1decc6c0de0a24d1cb4d09443451)
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/db/background.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/mongo/db/background.cpp b/src/mongo/db/background.cpp index 00341a4dbfd..638d6af2777 100644 --- a/src/mongo/db/background.cpp +++ b/src/mongo/db/background.cpp @@ -71,9 +71,10 @@ private: typedef StringMap<boost::shared_ptr<BgInfo>> BgInfoMap; typedef BgInfoMap::const_iterator BgInfoMapIterator; -boost::mutex m; -BgInfoMap dbsInProg; -BgInfoMap nsInProg; +// Static data for this file is never destroyed. +boost::mutex& m = *(new boost::mutex()); +BgInfoMap& dbsInProg = *(new BgInfoMap()); +BgInfoMap& nsInProg = *(new BgInfoMap()); void BgInfo::recordBegin() { ++_opsInProgCount; @@ -117,6 +118,7 @@ void awaitNoBgOps(boost::unique_lock<boost::mutex>& lk, BgInfoMap* bgiMap, const } } // namespace + bool BackgroundOperation::inProgForDb(const StringData& db) { boost::mutex::scoped_lock lk(m); return dbsInProg.find(db) != dbsInProg.end(); |