Port killWithUri functionality to C++

This commit is contained in:
Mathias Stearn
2010-08-17 18:09:53 -04:00
parent 37298e6142
commit b082b63f75
5 changed files with 19 additions and 36 deletions

View File

@@ -893,7 +893,8 @@ namespace mongo {
}
}
map< const void*, string > _allMyUris;
// connstr, myuris
map< string, set<string> > _allMyUris;
bool _nokillop = false;
void onConnect( DBClientWithCommands &c ) {
if ( _nokillop ) {
@@ -901,9 +902,8 @@ namespace mongo {
}
BSONObj info;
if ( c.runCommand( "admin", BSON( "whatsmyuri" << 1 ), info ) ) {
// There's no way to explicitly disconnect a DBClientConnection, but we might allocate
// a new uri on automatic reconnect. So just store one uri per connection.
_allMyUris[ &c ] = info[ "you" ].str();
string connstr = dynamic_cast<DBClientBase&>(c).getServerAddress();
_allMyUris[connstr].insert(info[ "you" ].str());
}
}
}