From 8a2bdb812ce335cdefb6d1688b68ff8e7968502f Mon Sep 17 00:00:00 2001 From: Mathias Stearn Date: Tue, 31 May 2011 16:30:15 -0400 Subject: [PATCH] SERVER-1790 WIP: use initLazy but still in separate thread --- client/parallel.cpp | 11 ++++++++++- client/parallel.h | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/client/parallel.cpp b/client/parallel.cpp index 4a7c304c5dde2..5e0860df26330 100644 --- a/client/parallel.cpp +++ b/client/parallel.cpp @@ -576,7 +576,16 @@ namespace mongo { conn = myconn->get(); } - res->_ok = conn->runCommand( res->_db , res->_cmd , res->_res ); + res->_cursor.reset( new DBClientCursor(conn, res->_db + ".$cmd", res->_cmd, -1/*limit*/, 0, NULL, 0, 0)); + res->_cursor->initLazy(); + //TODO: return here and resume later + + bool finished = res->_cursor->initLazyFinish(); + uassert(14812, str::stream() << "Error running command on server: " << res->_server, finished); + massert(14813, "Command returned nothing", res->_cursor->more()); + + res->_res = res->_cursor->nextSafe(); + res->_ok = res->_res["ok"].trueValue(); if ( myconn ) myconn->done(); diff --git a/client/parallel.h b/client/parallel.h index 09b5886b73ceb..4a6aa2a6283f4 100644 --- a/client/parallel.h +++ b/client/parallel.h @@ -288,6 +288,7 @@ namespace mongo { DBClientBase * _conn; scoped_ptr _thr; + scoped_ptr _cursor; BSONObj _res; bool _ok;