diff --git a/client/parallel.cpp b/client/parallel.cpp index d605ebd857e..a7568b2d83d 100644 --- a/client/parallel.cpp +++ b/client/parallel.cpp @@ -87,6 +87,8 @@ namespace mongo { auto_ptr cursor = conn->query( _ns , q , num , 0 , ( _fields.isEmpty() ? 0 : &_fields ) , _options , _batchSize == 0 ? 0 : _batchSize + skipLeft ); + + assert( cursor.get() ); if ( cursor->hasResultFlag( ResultFlag_ShardConfigStale ) ){ conn.done(); diff --git a/db/cloner.cpp b/db/cloner.cpp index 79d0c082e87..96890bf1417 100644 --- a/db/cloner.cpp +++ b/db/cloner.cpp @@ -172,9 +172,10 @@ namespace mongo { f.context = r._context; DBClientConnection *remote = dynamic_cast< DBClientConnection* >( conn.get() ); if ( remote ) { - remote->query( boost::function( f ), from_collection, query, 0, options ); + remote->query( boost::function( f ), from_collection, query, 0, options ); } else { // no exhaust mode for direct client, so we have this hack auto_ptr c = conn->query( from_collection, query, 0, 0, 0, options ); + assert( c.get() ); while( c->more() ) { DBClientCursorBatchIterator i( *c ); f( i ); diff --git a/db/repl/rs_rollback.cpp b/db/repl/rs_rollback.cpp index 42814101f76..dc0b89302d1 100644 --- a/db/repl/rs_rollback.cpp +++ b/db/repl/rs_rollback.cpp @@ -140,10 +140,10 @@ namespace mongo { //auto_ptr u = us->query(rsoplog, q, 0, 0, &fields, 0, 0); - h.rbid = getRBID(them); + h.rbid = getRBID(them); auto_ptr t = them->query(rsoplog, q, 0, 0, &fields, 0, 0); - if( !t->more() ) throw "remote oplog empty or unreadable"; + if( t.get() == 0 || !t->more() ) throw "remote oplog empty or unreadable"; BSONObj ourObj = u.current(); OpTime ourTime = ourObj["ts"]._opTime(); diff --git a/s/chunk.cpp b/s/chunk.cpp index cee7b0ea6cc..870e7aaa916 100644 --- a/s/chunk.cpp +++ b/s/chunk.cpp @@ -451,8 +451,11 @@ namespace mongo { // not using regular count as this is more flexible and supports $min/$max Query q = Query().minKey(_min).maxKey(_max); - int n = conn->query(_manager->getns(), q, maxCount, 0, &fields)->itcount(); - + int n; + { + auto_ptr c = conn->query(_manager->getns(), q, maxCount, 0, &fields); + n = c->itcount(); + } conn.done(); return n; } diff --git a/s/config.cpp b/s/config.cpp index e6bb48870c4..50682c67cb2 100644 --- a/s/config.cpp +++ b/s/config.cpp @@ -228,6 +228,7 @@ namespace mongo { auto_ptr cursor = conn->query( ShardNS::collection ,b.obj() ); + assert( cursor.get() ); while ( cursor->more() ){ BSONObj o = cursor->next(); _collections[o["_id"].String()] = CollectionInfo( this , o ); @@ -488,6 +489,7 @@ namespace mongo { ScopedDbConnection conn( _primary ); auto_ptr c = conn->query( ShardNS::settings , BSONObj() ); + assert( c.get() ); while ( c->more() ){ BSONObj o = c->next(); string name = o["_id"].valuestrsafe(); diff --git a/s/d_migrate.cpp b/s/d_migrate.cpp index 12b6ee3ae0c..f027f8bc611 100644 --- a/s/d_migrate.cpp +++ b/s/d_migrate.cpp @@ -788,6 +788,7 @@ namespace mongo { { // 3. initial bulk clone state = CLONE; auto_ptr cursor = conn->query( ns , Query().minKey( min ).maxKey( max ) , /* QueryOption_Exhaust */ 0 ); + assert( cursor.get() ); while ( cursor->more() ){ BSONObj o = cursor->next(); { diff --git a/s/d_state.cpp b/s/d_state.cpp index 26e44a1fcdd..dd2fecef45d 100644 --- a/s/d_state.cpp +++ b/s/d_state.cpp @@ -184,6 +184,7 @@ namespace mongo { } auto_ptr cursor = conn->query( "config.chunks" , Query(q).sort( "min" ) ); + assert( cursor.get() ); if ( ! cursor->more() ){ if ( scoped.get() ) scoped->done(); diff --git a/s/shard.cpp b/s/shard.cpp index 7879cc031dc..4ef68c0103c 100644 --- a/s/shard.cpp +++ b/s/shard.cpp @@ -33,6 +33,7 @@ namespace mongo { { ScopedDbConnection conn( configServer.getPrimary() ); auto_ptr c = conn->query( ShardNS::shard , Query() ); + assert( c.get() ); while ( c->more() ){ all.push_back( c->next().getOwned() ); } diff --git a/scripting/engine.cpp b/scripting/engine.cpp index 7b47a0fb2d1..9e20a3a031c 100644 --- a/scripting/engine.cpp +++ b/scripting/engine.cpp @@ -170,6 +170,7 @@ namespace mongo { static DBClientBase * db = createDirectClient(); auto_ptr c = db->query( coll , Query() ); + assert( c.get() ); set thisTime;