summaryrefslogtreecommitdiff
path: root/scripting
diff options
context:
space:
mode:
Diffstat (limited to 'scripting')
-rw-r--r--scripting/engine.cpp3
-rw-r--r--scripting/engine.h8
-rw-r--r--scripting/sm_db.cpp1
-rw-r--r--scripting/v8_db.cpp2
4 files changed, 13 insertions, 1 deletions
diff --git a/scripting/engine.cpp b/scripting/engine.cpp
index ab0d6dcc223..0dff413dbde 100644
--- a/scripting/engine.cpp
+++ b/scripting/engine.cpp
@@ -418,5 +418,8 @@ namespace mongo {
}
}
+ void ( *ScriptEngine::_connectCallback )( DBClientWithCommands & ) = 0;
+
ScriptEngine * globalScriptEngine;
}
+ \ No newline at end of file
diff --git a/scripting/engine.h b/scripting/engine.h
index 371c3ffb1da..9907d31244a 100644
--- a/scripting/engine.h
+++ b/scripting/engine.h
@@ -120,6 +120,8 @@ namespace mongo {
void installGlobalUtils( Scope& scope );
+ class DBClientWithCommands;
+
class ScriptEngine : boost::noncopyable {
public:
ScriptEngine();
@@ -146,12 +148,18 @@ namespace mongo {
virtual auto_ptr<Unlocker> newThreadUnlocker() { return auto_ptr< Unlocker >( new Unlocker ); }
void setScopeInitCallback( void ( *func )( Scope & ) ) { _scopeInitCallback = func; }
+ static void setConnectCallback( void ( *func )( DBClientWithCommands& ) ) { _connectCallback = func; }
+ static void runConnectCallback( DBClientWithCommands &c ) {
+ if ( _connectCallback )
+ _connectCallback( c );
+ }
protected:
virtual Scope * createScope() = 0;
private:
void ( *_scopeInitCallback )( Scope & );
+ static void ( *_connectCallback )( DBClientWithCommands & );
};
extern ScriptEngine * globalScriptEngine;
diff --git a/scripting/sm_db.cpp b/scripting/sm_db.cpp
index ca4526a3c40..b15c6b8e416 100644
--- a/scripting/sm_db.cpp
+++ b/scripting/sm_db.cpp
@@ -155,6 +155,7 @@ namespace mongo {
JS_ReportError( cx , ((string)"couldn't connect: " + errmsg).c_str() );
return JS_FALSE;
}
+ ScriptEngine::runConnectCallback( *c );
}
else { // paired
int numCommas = 0;
diff --git a/scripting/v8_db.cpp b/scripting/v8_db.cpp
index c328a53def3..7ba5d3a535d 100644
--- a/scripting/v8_db.cpp
+++ b/scripting/v8_db.cpp
@@ -156,7 +156,7 @@ namespace mongo {
if ( ! conn->connect( host , errmsg ) ){
return v8::ThrowException( v8::String::New( "couldn't connect" ) );
}
-
+ ScriptEngine::runConnectCallback( *conn );
// NOTE I don't believe the conn object will ever be freed.
args.This()->Set( CONN_STRING , External::New( conn ) );
args.This()->Set( v8::String::New( "slaveOk" ) , Boolean::New( false ) );