From 6c6d40a375924fc1433c853d4e66a60cedd57bcb Mon Sep 17 00:00:00 2001 From: Eliot Horowitz Date: Sun, 7 Feb 2010 01:38:54 -0500 Subject: [PATCH] moving some globals into a common file --- SConstruct | 2 +- db/common.cpp | 14 ++++++++++++++ db/instance.cpp | 4 ---- scripting/engine.cpp | 2 +- 4 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 db/common.cpp diff --git a/SConstruct b/SConstruct index 14b89bf6dd0..93fd99137a9 100644 --- a/SConstruct +++ b/SConstruct @@ -337,7 +337,7 @@ if GetOption( "extralib" ) is not None: # ------ SOURCE FILE SETUP ----------- -commonFiles = Split( "stdafx.cpp buildinfo.cpp db/jsobj.cpp db/json.cpp db/commands.cpp db/lasterror.cpp db/nonce.cpp db/queryutil.cpp shell/mongo.cpp" ) +commonFiles = Split( "stdafx.cpp buildinfo.cpp db/common.cpp db/jsobj.cpp db/json.cpp db/commands.cpp db/lasterror.cpp db/nonce.cpp db/queryutil.cpp shell/mongo.cpp" ) commonFiles += [ "util/background.cpp" , "util/mmap.cpp" , "util/sock.cpp" , "util/util.cpp" , "util/message.cpp" , "util/assert_util.cpp" , "util/httpclient.cpp" , "util/md5main.cpp" , "util/base64.cpp", "util/debug_util.cpp", "util/thread_pool.cpp" ] diff --git a/db/common.cpp b/db/common.cpp new file mode 100644 index 00000000000..05438bd6205 --- /dev/null +++ b/db/common.cpp @@ -0,0 +1,14 @@ +// common.cpp + +#include "../stdafx.h" +#include "concurrency.h" + +/** + * this just has globals + */ +namespace mongo { + + /* we use new here so we don't have to worry about destructor orders at program shutdown */ + MongoMutex &dbMutex( *(new MongoMutex) ); + +} diff --git a/db/instance.cpp b/db/instance.cpp index e0443427b7b..9422653bf2c 100644 --- a/db/instance.cpp +++ b/db/instance.cpp @@ -55,10 +55,6 @@ namespace mongo { bool master = false; // true means keep an op log bool autoresync = false; - /* we use new here so we don't have to worry about destructor orders at program shutdown */ - MongoMutex &dbMutex( *(new MongoMutex) ); -// MutexInfo dbMutexInfo; - string dbExecCommand; string bind_ip = ""; diff --git a/scripting/engine.cpp b/scripting/engine.cpp index 73eb7959b4f..a83588ff8f5 100644 --- a/scripting/engine.cpp +++ b/scripting/engine.cpp @@ -186,7 +186,7 @@ namespace mongo { } - if ( dbMutex.getState() > 0 ) + if ( dbMutex.getState() >= 0 ) db->ensureIndex( coll, BSON( "_id" << 1 ) , true ); // --- remove things from scope that were removed