summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Benvenuto <mark.benvenuto@mongodb.com>2014-03-17 11:53:07 -0400
committerDan Pasette <dan@mongodb.com>2014-03-17 18:56:57 -0400
commitc991426e46e416dfad3e433995a1bd2725e9b09c (patch)
tree5c0407551daf32ff94231c3723a338db7733ce98
parent1ac617e145b0c3f2238b67e833883a7ad6442fa5 (diff)
downloadmongo-c991426e46e416dfad3e433995a1bd2725e9b09c.tar.gz
SERVER-13033: Fix bad static initializer
(cherry picked from commit f0b367f3e04408f66fcc8f5bac1425155deec5c3)
-rw-r--r--src/mongo/scripting/engine.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/mongo/scripting/engine.cpp b/src/mongo/scripting/engine.cpp
index e6bb8be819e..694b12ae94f 100644
--- a/src/mongo/scripting/engine.cpp
+++ b/src/mongo/scripting/engine.cpp
@@ -22,6 +22,8 @@
#include <cctype>
#include <boost/filesystem/operations.hpp>
+#include "mongo/base/init.h"
+#include "mongo/base/initializer.h"
#include "mongo/client/dbclientcursor.h"
#include "mongo/client/dbclientinterface.h"
#include "mongo/scripting/bench.h"
@@ -30,6 +32,7 @@
namespace mongo {
long long Scope::_lastVersion = 1;
static const unsigned kMaxJsFileLength = std::numeric_limits<unsigned>::max() - 1;
+ static DBClientBase* directDBclient;
ScriptEngine::ScriptEngine() : _scopeInitCallback() {
}
@@ -157,6 +160,14 @@ namespace mongo {
uassert(10430, "invalid object id: not hex", std::isxdigit(str.at(i)));
}
+ MONGO_INITIALIZER(CreateJSDirectClient)
+ (InitializerContext* context) {
+
+ directDBclient = createDirectClient();
+
+ return Status::OK();
+ }
+
void Scope::loadStored(bool ignoreNotConnected) {
if (_localDBName.size() == 0) {
if (ignoreNotConnected)
@@ -170,8 +181,8 @@ namespace mongo {
_loadedVersion = _lastVersion;
string coll = _localDBName + ".system.js";
- static DBClientBase* db = createDirectClient();
- auto_ptr<DBClientCursor> c = db->query(coll, Query(), 0, 0, NULL, QueryOption_SlaveOk, 0);
+ auto_ptr<DBClientCursor> c = directDBclient->query(coll, Query(), 0, 0, NULL,
+ QueryOption_SlaveOk, 0);
massert(16669, "unable to get db client cursor from query", c.get());
set<string> thisTime;