diff options
author | Eliot Horowitz <eliot@10gen.com> | 2010-08-04 10:11:49 -0400 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2010-08-04 10:17:17 -0400 |
commit | c542dbd78a75511491596a427b67dbca62716a50 (patch) | |
tree | fc6711476f368dd629d25a6c0bd15755fc7f8c2f | |
parent | b5ce278c18496bc0d180b8d9ab976fdcf743f9a7 (diff) | |
download | mongo-c542dbd78a75511491596a427b67dbca62716a50.tar.gz |
when access namespace for the first time, prep all connections SERVER-1560
-rw-r--r-- | s/shardconnection.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/s/shardconnection.cpp b/s/shardconnection.cpp index 6c4bb1fe02a..5d89b51729d 100644 --- a/s/shardconnection.cpp +++ b/s/shardconnection.cpp @@ -26,6 +26,7 @@ namespace mongo { /** * holds all the actual db connections for a client to various servers + * 1 pre thread, so don't have to worry about thread safety */ class ClientConnections : boost::noncopyable { public: @@ -70,7 +71,8 @@ namespace mongo { _hosts.clear(); } - DBClientBase * get( const string& addr ){ + DBClientBase * get( const string& addr , const string& ns ){ + _check( ns ); scoped_lock lk( _mutex ); Status* &s = _hosts[addr]; if ( ! s ) @@ -152,9 +154,16 @@ namespace mongo { } } + void _check( const string& ns ){ + if ( ns.size() == 0 || _seenNS.count( ns ) ) + return; + _seenNS.insert( ns ); + checkVersions( ns ); + } + map<string,Status*> _hosts; mongo::mutex _mutex; - + set<string> _seenNS; // ----- static thread_specific_ptr<ClientConnections> _perThread; @@ -188,7 +197,7 @@ namespace mongo { void ShardConnection::_init(){ assert( _addr.size() ); - _conn = ClientConnections::get()->get( _addr ); + _conn = ClientConnections::get()->get( _addr , _ns ); _finishedInit = false; } |