0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-30 00:56:44 +01:00
This commit is contained in:
Dwight 2009-12-11 12:41:26 -05:00
parent b07d09c466
commit e42ea09fd1
2 changed files with 12 additions and 8 deletions

View File

@ -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 );

View File

@ -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() );