diff options
-rw-r--r-- | src/mongo/client/dbclient.cpp | 2 | ||||
-rw-r--r-- | src/mongo/client/dbclientinterface.h | 6 | ||||
-rw-r--r-- | src/mongo/s/shard_version.cpp | 8 |
3 files changed, 11 insertions, 5 deletions
diff --git a/src/mongo/client/dbclient.cpp b/src/mongo/client/dbclient.cpp index cb021da8d2d..1177cfd1172 100644 --- a/src/mongo/client/dbclient.cpp +++ b/src/mongo/client/dbclient.cpp @@ -36,6 +36,8 @@ namespace mongo { + AtomicInt64 DBClientBase::ConnectionIdSequence; + void ConnectionString::_fillServers( string s ) { // diff --git a/src/mongo/client/dbclientinterface.h b/src/mongo/client/dbclientinterface.h index 64ab61d6650..9d295838895 100644 --- a/src/mongo/client/dbclientinterface.h +++ b/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; } diff --git a/src/mongo/s/shard_version.cpp b/src/mongo/s/shard_version.cpp index ee959795027..fbb60ad06bf 100644 --- a/src/mongo/s/shard_version.cpp +++ b/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; |