summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
authorBen Becker <ben.becker@10gen.com>2013-02-12 12:32:24 -0800
committerDan Pasette <dan@10gen.com>2013-03-20 17:55:14 -0400
commit2048a8099765766aa772592ecb0e5a6d54530287 (patch)
treeae1d3a77d0b03e39cdb645b7794965497cab15e5 /src/mongo
parent33aa9495f99cc61659961ef7358fb31d8ba1b347 (diff)
downloadmongo-2048a8099765766aa772592ecb0e5a6d54530287.tar.gz
SERVER-8456: use CursorHolder to avoid auto_ptr::release
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/db/clientcursor.h1
-rw-r--r--src/mongo/db/commands/mr.cpp21
2 files changed, 10 insertions, 12 deletions
diff --git a/src/mongo/db/clientcursor.h b/src/mongo/db/clientcursor.h
index aebd23d4607..0283dde5e96 100644
--- a/src/mongo/db/clientcursor.h
+++ b/src/mongo/db/clientcursor.h
@@ -143,6 +143,7 @@ namespace mongo {
~Holder() {
DESTRUCTOR_GUARD ( reset(); );
}
+ ClientCursor* get() { return _c; }
operator bool() { return _c; }
ClientCursor * operator-> () { return _c; }
const ClientCursor * operator-> () const { return _c; }
diff --git a/src/mongo/db/commands/mr.cpp b/src/mongo/db/commands/mr.cpp
index b283bca37ef..13e378dedd9 100644
--- a/src/mongo/db/commands/mr.cpp
+++ b/src/mongo/db/commands/mr.cpp
@@ -768,10 +768,12 @@ namespace mongo {
verify( pm == op->setMessage( "m/r: (3/3) final reduce to collection" , _safeCount( _db, _config.incLong, BSONObj(), QueryOption_SlaveOk ) ) );
shared_ptr<Cursor> temp =
- NamespaceDetailsTransient::bestGuessCursor( _config.incLong.c_str() , BSONObj() ,
- sortKey );
- auto_ptr<ClientCursor> cursor( new ClientCursor( QueryOption_NoCursorTimeout , temp , _config.incLong.c_str() ) );
-
+ NamespaceDetailsTransient::bestGuessCursor(_config.incLong.c_str(),
+ BSONObj(),
+ sortKey);
+ ClientCursor::Holder cursor(new ClientCursor(QueryOption_NoCursorTimeout,
+ temp,
+ _config.incLong.c_str()));
// iterate over all sorted objects
while ( cursor->ok() ) {
BSONObj o = cursor->current().getOwned();
@@ -784,7 +786,6 @@ namespace mongo {
all.push_back( o );
if ( pm->hits() % 100 == 0 ) {
if ( ! cursor->yield() ) {
- cursor.release();
break;
}
killCurrentOp.checkForInterrupt();
@@ -800,7 +801,6 @@ namespace mongo {
}
catch (...) {
yield.relock();
- cursor.release();
throw;
}
@@ -809,15 +809,11 @@ namespace mongo {
all.push_back( o );
if ( ! yield.stillOk() ) {
- cursor.release();
break;
}
killCurrentOp.checkForInterrupt();
}
-
- // we need to release here since we temp release below
- cursor.release();
{
dbtempreleasecond tl;
@@ -1091,7 +1087,9 @@ namespace mongo {
// obtain full cursor on data to apply mr to
shared_ptr<Cursor> temp = NamespaceDetailsTransient::getCursor( config.ns.c_str(), config.filter, config.sort );
uassert( 16052, str::stream() << "could not create cursor over " << config.ns << " for query : " << config.filter << " sort : " << config.sort, temp.get() );
- auto_ptr<ClientCursor> cursor( new ClientCursor( QueryOption_NoCursorTimeout , temp , config.ns.c_str() ) );
+ ClientCursor::Holder cursor(new ClientCursor(QueryOption_NoCursorTimeout,
+ temp,
+ config.ns.c_str()));
uassert( 16053, str::stream() << "could not create client cursor over " << config.ns << " for query : " << config.filter << " sort : " << config.sort, cursor.get() );
Timer mt;
@@ -1132,7 +1130,6 @@ namespace mongo {
inReduce += t.micros();
if ( ! yield.stillOk() ) {
- cursor.release();
break;
}