summaryrefslogtreecommitdiff
path: root/shell/MongoJS.cpp
diff options
context:
space:
mode:
authorAaron <aaron@10gen.com>2009-03-04 16:55:24 -0500
committerAaron <aaron@10gen.com>2009-03-04 16:55:24 -0500
commit9be10a4f9844d669f6ccdc46b844d9f9a7283900 (patch)
treefb33fba9e3246dccedab721e080b8cdcfd7dd6d8 /shell/MongoJS.cpp
parent151383de17f5db1ed3e3930d8c18f7ff3e11abf4 (diff)
downloadmongo-9be10a4f9844d669f6ccdc46b844d9f9a7283900.tar.gz
For starters, unlock v8 when we expect a response from server
Diffstat (limited to 'shell/MongoJS.cpp')
-rw-r--r--shell/MongoJS.cpp21
1 files changed, 18 insertions, 3 deletions
diff --git a/shell/MongoJS.cpp b/shell/MongoJS.cpp
index e4176805e6d..d6d0b76dedc 100644
--- a/shell/MongoJS.cpp
+++ b/shell/MongoJS.cpp
@@ -325,7 +325,13 @@ Handle<Value> mongoFind(const Arguments& args){
bool slaveOk = slaveOkVal->BooleanValue();
try {
- auto_ptr<mongo::DBClientCursor> cursor = conn->query( ns, q , (int)(args[3]->ToNumber()->Value()) , (int)(args[4]->ToNumber()->Value()) , haveFields ? &fields : 0, slaveOk ? Option_SlaveOk : 0 );
+ auto_ptr<mongo::DBClientCursor> cursor;
+ int nToReturn = (int)(args[3]->ToNumber()->Value());
+ int nToSkip = (int)(args[4]->ToNumber()->Value());
+ {
+ v8::Unlocker u;
+ cursor = conn->query( ns, q , nToReturn , nToSkip , haveFields ? &fields : 0, slaveOk ? Option_SlaveOk : 0 );
+ }
v8::Function * cons = (v8::Function*)( *( mongo->Get( String::New( "internalCursor" ) ) ) );
Local<v8::Object> c = cons->NewInstance();
@@ -428,7 +434,11 @@ v8::Handle<v8::Value> internalCursorNext(const v8::Arguments& args){
mongo::DBClientCursor * cursor = getCursor( args );
if ( ! cursor )
return v8::Undefined();
- BSONObj o = cursor->next();
+ BSONObj o;
+ {
+ v8::Unlocker u;
+ o = cursor->next();
+ }
return mongoToV8( o );
}
@@ -436,7 +446,12 @@ v8::Handle<v8::Value> internalCursorHasNext(const v8::Arguments& args){
mongo::DBClientCursor * cursor = getCursor( args );
if ( ! cursor )
return Boolean::New( false );
- return Boolean::New( cursor->more() );
+ bool more;
+ {
+ v8::Unlocker u;
+ more = cursor->more();
+ }
+ return Boolean::New( more );
}