diff options
Diffstat (limited to 'db/dbcommands.cpp')
-rw-r--r-- | db/dbcommands.cpp | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/db/dbcommands.cpp b/db/dbcommands.cpp index 278565ea151..3464ac7b010 100644 --- a/db/dbcommands.cpp +++ b/db/dbcommands.cpp @@ -720,10 +720,11 @@ namespace mongo { seen.insert( i->c_str() ); } - - for ( map<string,Database*>::iterator i = databases.begin(); i != databases.end(); i++ ){ - string name = i->first; - name = name.substr( 0 , name.find( ":" ) ); + + set<string> allShortNames; + dbHolder.getAllShortNames( allShortNames ); + for ( set<string>::iterator i = allShortNames.begin(); i != allShortNames.end(); i++ ){ + string name = *i; if ( seen.count( name ) ) continue; @@ -748,18 +749,7 @@ namespace mongo { virtual bool slaveOk() { return false; } CmdCloseAllDatabases() : Command( "closeAllDatabases" ) {} bool run(const char *ns, BSONObj& jsobj, string& errmsg, BSONObjBuilder& result, bool /*fromRepl*/) { - set< string > dbs; - for ( map<string,Database*>::iterator i = databases.begin(); i != databases.end(); i++ ) { - string name = i->first; - name = name.substr( 0 , name.find( ":" ) ); - dbs.insert( name ); - } - for( set< string >::iterator i = dbs.begin(); i != dbs.end(); ++i ) { - setClient( i->c_str() ); - closeDatabase( i->c_str() ); - } - - return true; + return dbHolder.closeAll( dbpath , result ); } } cmdCloseAllDatabases; |