Skip to content

Commit

Permalink
SERVER-22160 Make statics for background.cpp immortal
Browse files Browse the repository at this point in the history
This resolves static-initialization-order-fiasco problems with
cursor_manager.cpp.
  • Loading branch information
RedBeard0531 committed Jan 14, 2016
1 parent 1fd3ccc commit d9e0595
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/mongo/db/background.cpp
Expand Up @@ -71,9 +71,10 @@ class BgInfo {
typedef StringMap<std::shared_ptr<BgInfo>> BgInfoMap;
typedef BgInfoMap::const_iterator BgInfoMapIterator;

stdx::mutex m;
BgInfoMap dbsInProg;
BgInfoMap nsInProg;
// Static data for this file is never destroyed.
stdx::mutex& m = *(new stdx::mutex());
BgInfoMap& dbsInProg = *(new BgInfoMap());
BgInfoMap& nsInProg = *(new BgInfoMap());

void BgInfo::recordBegin() {
++_opsInProgCount;
Expand Down Expand Up @@ -116,6 +117,7 @@ void awaitNoBgOps(stdx::unique_lock<stdx::mutex>& lk, BgInfoMap* bgiMap, StringD
}

} // namespace

bool BackgroundOperation::inProgForDb(StringData db) {
stdx::lock_guard<stdx::mutex> lk(m);
return dbsInProg.find(db) != dbsInProg.end();
Expand Down

0 comments on commit d9e0595

Please sign in to comment.