summaryrefslogtreecommitdiff
path: root/scripting/sm_db.cpp
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2009-05-14 17:37:48 -0400
committerEliot Horowitz <eliot@10gen.com>2009-05-14 17:37:48 -0400
commit7030e2b584de107ff572c78e1a239b109daa8f50 (patch)
treef2c3329e5bfabb5f4e870e40143f01431e5c2a6e /scripting/sm_db.cpp
parent6a06a6cb3ca94f516180547c2f68e6ba75d4aa7e (diff)
parentdf9fe97f790d0a6ac654c17540048faf55104846 (diff)
downloadmongo-7030e2b584de107ff572c78e1a239b109daa8f50.tar.gz
Merge branch 'smshell' of git@github.com:mongodb/mongo into smshell
Diffstat (limited to 'scripting/sm_db.cpp')
-rw-r--r--scripting/sm_db.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/scripting/sm_db.cpp b/scripting/sm_db.cpp
index e7d19c8b138..c4d0038064a 100644
--- a/scripting/sm_db.cpp
+++ b/scripting/sm_db.cpp
@@ -484,11 +484,10 @@ namespace mongo {
JS_AddRoot( cx, &fun_ );
for( uintN i = 0; i < argc_; ++i )
JS_AddRoot( cx, &argv_[ i ] );
- scope_.reset( dynamic_cast< SMScope * >( globalScriptEngine->createScope() ) );
- scope_->externalSetup();
}
~JSThreadConfig() {
- thread_->join(); // don't want to deal with cleaning up while thread is running
+ if ( started_ )
+ thread_->join(); // don't want to deal with cleaning up while thread is running
JS_RemoveRoot( cx_, &obj_ );
JS_RemoveRoot( cx_, &fun_ );
for( uintN i = 0; i < argc_; ++i )
@@ -498,6 +497,9 @@ namespace mongo {
}
void start() {
massert( "Thread already started", !started_ );
+ scope_.reset( dynamic_cast< SMScope * >( globalScriptEngine->createScope() ) );
+ scope_->externalSetup( true );
+ // TODO install shell utils?
JSThread jt( *this );
thread_.reset( new boost::thread( jt ) );
started_ = true;
@@ -590,7 +592,7 @@ namespace mongo {
// ---- other stuff ----
- void initMongoJS( SMScope * scope , JSContext * cx , JSObject * global , bool local ){
+ void initMongoJS( SMScope * scope , JSContext * cx , JSObject * global , bool local, bool debug ){
assert( JS_InitClass( cx , global , 0 , &mongo_class , local ? mongo_local_constructor : mongo_external_constructor , 0 , 0 , mongo_functions , 0 , 0 ) );
@@ -601,8 +603,11 @@ namespace mongo {
assert( JS_InitClass( cx , global , 0 , &dbquery_class , dbquery_constructor , 0 , 0 , 0 , 0 , 0 ) );
assert( JS_InitClass( cx , global , 0 , &thread_class , thread_constructor , 0 , 0 , thread_functions , 0 , 0 ) );
+ if ( !debug ) {
+
scope->exec( jsconcatcode );
+ }
}
bool appendSpecialDBObject( Convertor * c , BSONObjBuilder& b , const string& name , JSObject * o ){