4747namespace mongo {
4848
4949 Database* DatabaseHolder::get (OperationContext* txn,
50- const std::string& ns,
51- const std::string& path) const {
50+ const std::string& ns) const {
5251
5352 txn->lockState ()->assertAtLeastReadLocked (ns);
5453
5554 SimpleMutex::scoped_lock lk (_m);
56- Paths::const_iterator x = _paths.find ( path );
57- if ( x == _paths.end () )
58- return 0 ;
59- const DBs& m = x->second ;
6055 const std::string db = _todb ( ns );
61- DBs::const_iterator it = m .find (db);
62- if ( it != m .end () )
56+ DBs::const_iterator it = _dbs .find (db);
57+ if ( it != _dbs .end () )
6358 return it->second ;
6459 return NULL ;
6560 }
6661
67- Database* DatabaseHolder::getOrCreate (
68- OperationContext* txn, const string& ns, const string& path, bool & justCreated) {
62+ Database* DatabaseHolder::getOrCreate (OperationContext* txn,
63+ const string& ns,
64+ bool & justCreated) {
6965
7066 const string dbname = _todb ( ns );
7167 invariant (txn->lockState ()->isAtLeastReadLocked (dbname));
@@ -76,10 +72,9 @@ namespace mongo {
7672
7773 {
7874 SimpleMutex::scoped_lock lk (_m);
79- DBs& m = _paths[path];
8075 {
81- DBs::iterator i = m .find (dbname);
82- if ( i != m .end () ) {
76+ DBs::iterator i = _dbs .find (dbname);
77+ if ( i != _dbs .end () ) {
8378 justCreated = false ;
8479 return i->second ;
8580 }
@@ -90,10 +85,8 @@ namespace mongo {
9085 // perhaps just log it, which is what we do here with the "> 40" :
9186 bool cant = !txn->lockState ()->isWriteLocked (ns);
9287 if ( logger::globalLogDomain ()->shouldLog (logger::LogSeverity::Debug (1 )) ||
93- m.size () > 40 || cant || DEBUG_BUILD ) {
94- log () << " opening db: "
95- << (path == storageGlobalParams.dbpath ? " " : path) << ' ' << dbname
96- << endl;
88+ _dbs.size () > 40 || cant || DEBUG_BUILD ) {
89+ log () << " opening db: " << dbname;
9790 }
9891 massert (15927 , " can't open database in a read lock. if db was just closed, consider retrying the query. might otherwise indicate an internal error" , !cant);
9992 }
@@ -107,43 +100,36 @@ namespace mongo {
107100 dbname,
108101 justCreated,
109102 new MMAPV1DatabaseCatalogEntry (txn,
110- dbname,
111- path,
112- storageGlobalParams.directoryperdb ));
103+ dbname,
104+ storageGlobalParams.dbpath ,
105+ storageGlobalParams.directoryperdb ,
106+ false ));
113107
114108 {
115109 SimpleMutex::scoped_lock lk (_m);
116- DBs& m = _paths[path];
117- verify ( m[dbname] == 0 );
118- m[dbname] = db;
119- _size++;
110+ _dbs[dbname] = db;
120111 }
121112
122113 return db;
123114 }
124115
125116 void DatabaseHolder::erase (OperationContext* txn,
126- const std::string& ns,
127- const std::string& path) {
117+ const std::string& ns) {
128118 invariant (txn->lockState ()->isW ());
129119
130120 SimpleMutex::scoped_lock lk (_m);
131- DBs& m = _paths[path];
132- _size -= (int )m.erase (_todb (ns));
121+ _dbs.erase (_todb (ns));
133122 }
134123
135- bool DatabaseHolder::closeAll (
136- OperationContext* txn, const string& path, BSONObjBuilder& result, bool force) {
137- log () << " DatabaseHolder::closeAll path: " << path << endl;
124+ bool DatabaseHolder::closeAll (OperationContext* txn,
125+ BSONObjBuilder& result,
126+ bool force) {
138127 invariant (txn->lockState ()->isW ());
139128
140129 getDur ().commitNow (txn); // bad things happen if we close a DB with outstanding writes
141130
142- map<string,Database*>& m = _paths[path];
143- _size -= m.size ();
144-
145131 set< string > dbs;
146- for ( map<string,Database*>::iterator i = m .begin (); i != m .end (); i++ ) {
132+ for ( map<string,Database*>::iterator i = _dbs .begin (); i != _dbs .end (); i++ ) {
147133 dbs.insert ( i->first );
148134 }
149135
@@ -152,8 +138,8 @@ namespace mongo {
152138 int nNotClosed = 0 ;
153139 for ( set< string >::iterator i = dbs.begin (); i != dbs.end (); ++i ) {
154140 string name = *i;
155- LOG (2 ) << " DatabaseHolder::closeAll path: " << path << " name:" << name << endl ;
156- Client::Context ctx ( name , path );
141+ LOG (2 ) << " DatabaseHolder::closeAll name:" << name;
142+ Client::Context ctx ( name );
157143 if ( !force && BackgroundOperation::inProgForDb (name) ) {
158144 log () << " WARNING: can't close database "
159145 << name
@@ -162,7 +148,7 @@ namespace mongo {
162148 nNotClosed++;
163149 }
164150 else {
165- Database::closeDatabase (txn, name.c_str (), path );
151+ Database::closeDatabase (txn, name.c_str ());
166152 bb.append ( bb.numStr ( n++ ) , name );
167153 }
168154 }
0 commit comments