Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

SERVER-7460 Make sure connections never get version information assoc…

…iated with them from an old connection
  • Loading branch information...
commit 3cc3b033b4b8f9e969655128da3c5951a4e9fa33 1 parent 39f9638
@stbrody stbrody authored milkie committed
View
2  src/mongo/client/dbclient.cpp
@@ -36,6 +36,8 @@
namespace mongo {
+ AtomicInt64 DBClientBase::ConnectionIdSequence;
+
void ConnectionString::_fillServers( string s ) {
//
View
6 src/mongo/client/dbclientinterface.h
@@ -921,13 +921,17 @@ namespace mongo {
*/
class DBClientBase : public DBClientWithCommands, public DBConnector {
protected:
+ static AtomicInt64 ConnectionIdSequence;
+ long long _connectionId; // unique connection id for this connection
WriteConcern _writeConcern;
-
public:
DBClientBase() {
_writeConcern = W_NORMAL;
+ _connectionId = ConnectionIdSequence.fetchAndAdd(1);
}
+ long long getConnectionId() const { return _connectionId; }
+
WriteConcern getWriteConcern() const { return _writeConcern; }
void setWriteConcern( WriteConcern w ) { _writeConcern = w; }
View
8 src/mongo/s/shard_version.cpp
@@ -43,24 +43,24 @@ namespace mongo {
S getSequence( DBClientBase * conn , const string& ns ) {
scoped_lock lk( _mutex );
- return _map[conn][ns];
+ return _map[conn->getConnectionId()][ns];
}
void setSequence( DBClientBase * conn , const string& ns , const S& s ) {
scoped_lock lk( _mutex );
- _map[conn][ns] = s;
+ _map[conn->getConnectionId()][ns] = s;
}
void reset( DBClientBase * conn ) {
scoped_lock lk( _mutex );
- _map.erase( conn );
+ _map.erase( conn->getConnectionId() );
}
// protects _map
mongo::mutex _mutex;
// a map from a connection into ChunkManager's sequence number for each namespace
- map<DBClientBase*, map<string,unsigned long long> > _map;
+ unordered_map<unsigned long long, map<string,unsigned long long> > _map;
} connectionShardStatus;
Please sign in to comment.
Something went wrong with that request. Please try again.