|
@@ -712,8 +712,31 @@ void traceSlowReadTms(const char *msg, ISocket *sock, void *dst, size32_t minSiz
|
|
|
|
|
|
struct ConnectHdr
|
|
|
{
|
|
|
+ ConnectHdr(const SocketEndpoint &hostEp, const SocketEndpoint &remoteEp, unsigned __int64 role)
|
|
|
+ {
|
|
|
+ id[0].set(hostEp);
|
|
|
+ id[1].set(remoteEp);
|
|
|
+
|
|
|
+ hdr.size = sizeof(PacketHeader);
|
|
|
+ hdr.tag = TAG_SYS_BCAST;
|
|
|
+ hdr.flags = 0;
|
|
|
+ hdr.version = MP_PROTOCOL_VERSION;
|
|
|
+ setRole(role);
|
|
|
+ }
|
|
|
+ ConnectHdr()
|
|
|
+ {
|
|
|
+ }
|
|
|
SocketEndpointV4 id[2];
|
|
|
- unsigned __int64 role;
|
|
|
+ PacketHeader hdr;
|
|
|
+ inline void setRole(unsigned __int64 role)
|
|
|
+ {
|
|
|
+ hdr.replytag = (mptag_t) (role >> 32);
|
|
|
+ hdr.sequence = (unsigned) (role & 0xffffffff);
|
|
|
+ }
|
|
|
+ inline unsigned __int64 getRole() const
|
|
|
+ {
|
|
|
+ return (((unsigned __int64)hdr.replytag)<<32) | ((unsigned __int64)hdr.sequence);
|
|
|
+ }
|
|
|
};
|
|
|
|
|
|
|
|
@@ -794,12 +817,9 @@ protected: friend class CMPPacketReader;
|
|
|
LOG(MCdebugInfo(100), unknownJob, "MP: connect after socket connect, retrycount = %d", retrycount);
|
|
|
#endif
|
|
|
|
|
|
- ConnectHdr connectHdr;
|
|
|
SocketEndpoint hostep;
|
|
|
hostep.setLocalHost(parent->getPort());
|
|
|
- connectHdr.id[0].set(hostep);
|
|
|
- connectHdr.id[1].set(remoteep);
|
|
|
- connectHdr.role = parent->getRole();
|
|
|
+ ConnectHdr connectHdr(hostep, remoteep, parent->getRole());
|
|
|
|
|
|
unsigned __int64 addrval = DIGIT1*connectHdr.id[0].ip[0] + DIGIT2*connectHdr.id[0].ip[1] + DIGIT3*connectHdr.id[0].ip[2] + DIGIT4*connectHdr.id[0].ip[3] + connectHdr.id[0].port;
|
|
|
#ifdef _TRACE
|
|
@@ -2046,7 +2066,7 @@ int CMPConnectThread::run()
|
|
|
else
|
|
|
{
|
|
|
if (rd == sizeof(connectHdr.id)) // legacy client
|
|
|
- connectHdr.role = 0; // unknown
|
|
|
+ connectHdr.setRole(0); // unknown
|
|
|
else if (rd < sizeof(connectHdr.id) || rd > sizeof(connectHdr))
|
|
|
{
|
|
|
// not sure how to get here as this is not one of the possible outcomes of above: rd == 0 or rd == sizeof(id) or an exception
|