summaryrefslogtreecommitdiff
path: root/db/namespace.cpp
diff options
context:
space:
mode:
authorAaron <aaron@10gen.com>2009-03-03 15:27:22 -0500
committerAaron <aaron@10gen.com>2009-03-03 15:27:22 -0500
commitdbaa985014311d07587bb282cc1944265b94d97d (patch)
tree78e29943d5c0a6079218f43dde2226735eab5440 /db/namespace.cpp
parent56dacac4d7a9ec9180cf946512aeed81c799c2b8 (diff)
downloadmongo-dbaa985014311d07587bb282cc1944265b94d97d.tar.gz
Reset NamespaceDetailsTransient and clear query cache on drop database
Diffstat (limited to 'db/namespace.cpp')
-rw-r--r--db/namespace.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/db/namespace.cpp b/db/namespace.cpp
index 456726f4cb4..c27e63d43ca 100644
--- a/db/namespace.cpp
+++ b/db/namespace.cpp
@@ -502,8 +502,8 @@ namespace mongo {
/* ------------------------------------------------------------------------- */
- map<string,NamespaceDetailsTransient*> NamespaceDetailsTransient::map;
- typedef map<string,NamespaceDetailsTransient*>::iterator ouriter;
+ map< string, shared_ptr< NamespaceDetailsTransient > > NamespaceDetailsTransient::map;
+ typedef map< string, shared_ptr< NamespaceDetailsTransient > >::iterator ouriter;
void NamespaceDetailsTransient::reset() {
clearQueryCache( ns.c_str() );
@@ -511,12 +511,22 @@ namespace mongo {
}
NamespaceDetailsTransient& NamespaceDetailsTransient::get(const char *ns) {
- NamespaceDetailsTransient*& t = map[ns];
- if ( t == 0 )
- t = new NamespaceDetailsTransient(ns);
+ shared_ptr< NamespaceDetailsTransient > &t = map[ ns ];
+ if ( t.get() == 0 )
+ t.reset( new NamespaceDetailsTransient(ns) );
return *t;
}
+ void NamespaceDetailsTransient::drop(const char *ns) {
+ vector< string > found;
+ for( ouriter i = map.begin(); i != map.end(); ++i )
+ if ( strncmp( i->first.c_str(), ns, strlen( ns ) ) == 0 )
+ found.push_back( i->first );
+ for( vector< string >::iterator i = found.begin(); i != found.end(); ++i ) {
+ map[ *i ].reset();
+ }
+ }
+
void NamespaceDetailsTransient::computeIndexKeys() {
allIndexKeys.clear();
NamespaceDetails *d = nsdetails(ns.c_str());