diff --git a/db/db.cpp b/db/db.cpp index 2b705b1461f..6da1caed3fa 100644 --- a/db/db.cpp +++ b/db/db.cpp @@ -366,8 +366,10 @@ namespace mongo { vector< string > toDelete; DBDirectClient cli; auto_ptr< DBClientCursor > c = cli.query( "local.system.namespaces", Query( fromjson( "{name:/^local.temp./}" ) ) ); - while( c->more() ) - toDelete.push_back( c->next().getStringField( "name" ) ); + while( c->more() ) { + BSONObj o = c->next(); + toDelete.push_back( o.getStringField( "name" ) ); + } for( vector< string >::iterator i = toDelete.begin(); i != toDelete.end(); ++i ) { log() << "Dropping old temporary collection: " << *i << endl; cli.dropCollection( *i ); diff --git a/db/instance.h b/db/instance.h index 5e02b574515..9583e362f06 100644 --- a/db/instance.h +++ b/db/instance.h @@ -138,24 +138,26 @@ namespace mongo { public: SavedContext() { _save = dbMutex.atLeastReadLocked(); + + Client *c = currentClient.get(); + oldAuth = c->ai; + // careful, don't want to free this: + c->ai = &always; + /* it only makes sense to manipulate a pointer - c->database() - if locked. thus the _saved flag. */ if( _save ) { - Client *c = currentClient.get(); if ( c->database() ) { dbMutex.assertAtLeastReadLocked(); _oldName = c->database()->name; } - oldAuth = c->ai; - // careful, don't want to free this: - c->ai = &always; } } ~SavedContext() { + Client *c = currentClient.get(); + c->ai = oldAuth; if( _save ) { - Client *c = currentClient.get(); - c->ai = oldAuth; if ( !_oldName.empty() ) { dbMutex.assertAtLeastReadLocked(); setClient( _oldName.c_str() );