diff options
Diffstat (limited to 'src/mongo/db/pdfile.cpp')
-rw-r--r-- | src/mongo/db/pdfile.cpp | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/src/mongo/db/pdfile.cpp b/src/mongo/db/pdfile.cpp index 655c1a6041e..4cc0552ebc0 100644 --- a/src/mongo/db/pdfile.cpp +++ b/src/mongo/db/pdfile.cpp @@ -106,19 +106,20 @@ namespace mongo { * @param createDefaultIndexes - if false, defers id (and other) index creation. * @return true if successful */ - Status userCreateNS( const StringData& ns, + Status userCreateNS( Database* db, + const StringData& ns, BSONObj options, bool logForReplication, bool createDefaultIndexes ) { + invariant( db ); + LOG(1) << "create collection " << ns << ' ' << options; if ( !NamespaceString::validCollectionComponent(ns) ) return Status( ErrorCodes::InvalidNamespace, str::stream() << "invalid ns: " << ns ); - Database* db = cc().database(); - Collection* collection = db->getCollection( ns ); if ( collection ) @@ -156,21 +157,22 @@ namespace mongo { for( vector<string>::iterator i = n.begin(); i != n.end(); i++ ) { if( *i != "local" ) { Client::Context ctx(*i); - dropDatabase(*i); + dropDatabase(ctx.db()); } } } - void dropDatabase(const std::string& db) { - LOG(1) << "dropDatabase " << db << endl; - Lock::assertWriteLocked(db); - Database *d = cc().database(); - verify( d ); - verify( d->name() == db ); + void dropDatabase(Database* db ) { + invariant( db ); + + string name = db->name(); // just to have safe + LOG(1) << "dropDatabase " << name << endl; + + Lock::assertWriteLocked( name ); - BackgroundOperation::assertNoBgOpInProgForDb(d->name().c_str()); + BackgroundOperation::assertNoBgOpInProgForDb(name.c_str()); - audit::logDropDatabase( currentClient.get(), db ); + audit::logDropDatabase( currentClient.get(), name ); // Not sure we need this here, so removed. If we do, we need to move it down // within other calls both (1) as they could be called from elsewhere and @@ -181,10 +183,10 @@ namespace mongo { getDur().syncDataAndTruncateJournal(); - Database::closeDatabase( d->name(), d->path() ); - d = 0; // d is now deleted + Database::closeDatabase( name, db->path() ); + db = 0; // d is now deleted - _deleteDataFiles( db ); + _deleteDataFiles( name ); } } // namespace mongo |