summaryrefslogtreecommitdiff
path: root/db/dbcommands.cpp
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2010-01-02 01:25:53 -0500
committerEliot Horowitz <eliot@10gen.com>2010-01-02 01:25:53 -0500
commitfcf2d5721c4e233009e12b0db325b164327db377 (patch)
treed795a7ae80bf35e450bc93e7e8e810a965c91eca /db/dbcommands.cpp
parent23326c222d8a88c6d4b372a348241528a8726b5c (diff)
downloadmongo-fcf2d5721c4e233009e12b0db325b164327db377.tar.gz
some cleaning/optmizing of Database* storage, also just a little encaspulation
Diffstat (limited to 'db/dbcommands.cpp')
-rw-r--r--db/dbcommands.cpp22
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;