summaryrefslogtreecommitdiff
path: root/src/mongo/scripting/engine.h
diff options
context:
space:
mode:
authorKaloian Manassiev <kaloian.manassiev@mongodb.com>2014-07-24 14:44:23 -0400
committerKaloian Manassiev <kaloian.manassiev@mongodb.com>2014-07-28 17:14:17 -0400
commit78d2f38aa445ef1658300e66e1db14b9f1eceba8 (patch)
treed8503e6badb65230017c5c6a4042983283b11933 /src/mongo/scripting/engine.h
parent5e515de16fe1eac1f7079a2a95aa9e4f716ee3ec (diff)
downloadmongo-78d2f38aa445ef1658300e66e1db14b9f1eceba8.tar.gz
SERVER-13961 Pass through OperationContext in the JS framework
The JS framework uses DBDirectClient, which requires OperationContext in order to not conflict with locks, which have already been acquired. This change also makes dbEval not use pooled scopes and create a new scope instead.
Diffstat (limited to 'src/mongo/scripting/engine.h')
-rw-r--r--src/mongo/scripting/engine.h21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/mongo/scripting/engine.h b/src/mongo/scripting/engine.h
index ec4c1667481..7a3d4b67a8b 100644
--- a/src/mongo/scripting/engine.h
+++ b/src/mongo/scripting/engine.h
@@ -38,27 +38,31 @@ namespace mongo {
class DBClientWithCommands;
class DBClientBase;
+ class OperationContext;
struct JSFile {
const char* name;
const StringData& source;
};
- class Scope : boost::noncopyable {
+ class Scope {
+ MONGO_DISALLOW_COPYING(Scope);
public:
Scope();
virtual ~Scope();
virtual void reset() = 0;
virtual void init(const BSONObj* data) = 0;
+
void init(const char* data) {
BSONObj o(data);
init(&o);
}
- virtual void localConnect(const char* dbName) = 0;
+ virtual void localConnectForDbEval(OperationContext* txn, const char* dbName) = 0;
virtual void externalSetup() = 0;
virtual void setLocalDB(const std::string& localDBName) { _localDBName = localDBName; }
+
virtual BSONObj getObject(const char* field) = 0;
virtual std::string getString(const char* field) = 0;
virtual bool getBoolean(const char* field) = 0;
@@ -135,7 +139,7 @@ namespace mongo {
void execCoreFiles();
- virtual void loadStored(bool ignoreNotConnected = false);
+ virtual void loadStored(OperationContext* txn, bool ignoreNotConnected = false);
/**
* if any changes are made to .system.js, call this
@@ -149,7 +153,7 @@ namespace mongo {
void incTimesUsed() { ++_numTimesUsed; }
/** gets the number of times a scope was used */
- int getTimesUsed() { return _numTimesUsed; }
+ int getTimesUsed() const { return _numTimesUsed; }
/** return true if last invoke() return'd native code */
virtual bool isLastRetNativeCode() { return _lastRetIsNativeCode; }
@@ -183,7 +187,8 @@ namespace mongo {
bool _lastRetIsNativeCode; // v8 only: set to true if eval'd script returns a native func
};
- class ScriptEngine : boost::noncopyable {
+ class ScriptEngine {
+ MONGO_DISALLOW_COPYING(ScriptEngine);
public:
ScriptEngine();
virtual ~ScriptEngine();
@@ -204,7 +209,9 @@ namespace mongo {
* This must include authenticated users.
* @return the scope
*/
- std::auto_ptr<Scope> getPooledScope(const std::string& db, const std::string& scopeType);
+ std::auto_ptr<Scope> getPooledScope(OperationContext* txn,
+ const std::string& db,
+ const std::string& scopeType);
void setScopeInitCallback(void (*func)(Scope&)) { _scopeInitCallback = func; }
static void setConnectCallback(void (*func)(DBClientWithCommands&)) {
@@ -255,5 +262,7 @@ namespace mongo {
bool hasJSReturn(const std::string& s);
const char* jsSkipWhiteSpace(const char* raw);
+ DBClientBase* createDirectClient(OperationContext* txn);
+
extern ScriptEngine* globalScriptEngine;
}