diff options
author | Eliot Horowitz <eliot@10gen.com> | 2010-02-07 01:10:12 -0500 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2010-02-07 01:10:12 -0500 |
commit | 1342db66743eeff1c7f72003d77f097692084d88 (patch) | |
tree | 12a4e3a929aae2b5443157fa911a2cd1711d971d /scripting/engine.cpp | |
parent | 656cd3a9f46625f4b3223030e8ffe5f51233ca3d (diff) | |
download | mongo-1342db66743eeff1c7f72003d77f097692084d88.tar.gz |
clean up scope from things removed from system.js SERVER-602
Diffstat (limited to 'scripting/engine.cpp')
-rw-r--r-- | scripting/engine.cpp | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/scripting/engine.cpp b/scripting/engine.cpp index c2651b3a883..515f1386e0c 100644 --- a/scripting/engine.cpp +++ b/scripting/engine.cpp @@ -164,9 +164,12 @@ namespace mongo { _loadedVersion = _lastVersion; string coll = _localDBName + ".system.js"; - + static DBClientBase * db = createDirectClient(); auto_ptr<DBClientCursor> c = db->query( coll , Query() ); + + set<string> thisTime; + while ( c->more() ){ BSONObj o = c->next(); @@ -177,10 +180,30 @@ namespace mongo { uassert( 10210 , "value has to be set" , v.type() != EOO ); setElement( n.valuestr() , v ); + + thisTime.insert( n.valuestr() ); + _storedNames.insert( n.valuestr() ); + } db->ensureIndex( coll, BSON( "_id" << 1 ) , true ); + + // --- remove things from scope that were removed + + list<string> toremove; + + for ( set<string>::iterator i=_storedNames.begin(); i!=_storedNames.end(); i++ ){ + string n = *i; + if ( thisTime.count( n ) == 0 ) + toremove.push_back( n ); + } + for ( list<string>::iterator i=toremove.begin(); i!=toremove.end(); i++ ){ + string n = *i; + _storedNames.erase( n ); + execSetup( (string)"delete " + n , "clean up scope" ); + } + } ScriptingFunction Scope::createFunction( const char * code ){ |