summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2011-03-16 12:33:54 -0400
committerEliot Horowitz <eliot@10gen.com>2011-03-16 15:54:40 -0400
commitfade9c4e5160c90da06e767158b85fb679da05dd (patch)
treeaa0aa0e00757a5bc02ef22ceafa43d8183a8d6dc
parent3d083de24be208d426817cc8cc9f4f24be520609 (diff)
downloadmongo-fade9c4e5160c90da06e767158b85fb679da05dd.tar.gz
more accurate client id
-rw-r--r--util/message.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/util/message.cpp b/util/message.cpp
index 16ba4c4fcaf..37099dcbbc5 100644
--- a/util/message.cpp
+++ b/util/message.cpp
@@ -775,9 +775,19 @@ again:
int AbstractMessagingPort::getClientId() {
if ( _clientId == 0 ) {
+ /**
+ * highest 2 bytes is port
+ * this is unique except when there are multiple ips
+ * or can be issue with high connection churn
+ *
+ * lowest 2 bytes is part of the address
+ * space there is 128 * 2^16
+ * so if there is 8gb of heap area for sockets, then this 100% unique
+ */
+ DEV assert( sizeof( MessagingPort ) > 128 );
int x = remotePort();
x = x << 16;
- x |= ( ( 0xFF0 & (long long)this ) >> 9 ); // lowest byte in pointer often meaningless
+ x |= ( ( (long long)this >> 7 ) & 0xFFFF ); // lowest 7 bits isn't helpful
_clientId = x;
}
return _clientId;