From ae80a66ff8d30bc9785d12a5f9d8fafd0bc37e2a Mon Sep 17 00:00:00 2001 From: Aaron Date: Mon, 22 Feb 2010 10:32:55 -0800 Subject: SERVER-305 record uri on connect --- scripting/engine.cpp | 3 +++ scripting/engine.h | 8 ++++++++ scripting/sm_db.cpp | 1 + scripting/v8_db.cpp | 2 +- 4 files changed, 13 insertions(+), 1 deletion(-) (limited to 'scripting') 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 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 ) ); -- cgit v1.2.1