Browse Source

HPCC-8390 Don't rely on offsetof

Signed-off-by: Renato Golin <rengolin@hpccsystems.com>
Renato Golin 12 years ago
parent
commit
2fcc69b552
2 changed files with 6 additions and 1 deletions
  1. 5 0
      roxie/udplib/udpsha.hpp
  2. 1 1
      roxie/udplib/udptrr.cpp

+ 5 - 0
roxie/udplib/udpsha.hpp

@@ -187,6 +187,11 @@ struct UdpPermitToSendMsg
     unsigned        missingCount;
 #ifdef CRC_MESSAGES
     unsigned        crc;
+    // Change this value when new fields are added above (+crc)
+    static const size_t messageFixedSize = 4*sizeof(unsigned short) + 3*sizeof(unsigned);
+#else
+    // Change this value when new fields are added above
+    static const size_t messageFixedSize = 4*sizeof(unsigned short) + 2*sizeof(unsigned);
 #endif
     unsigned        missingSequences[MAX_RESEND_TABLE_SIZE]; // only [missingCount] actually sent
 

+ 1 - 1
roxie/udplib/udptrr.cpp

@@ -230,7 +230,7 @@ class CReceiveManager : public CInterface, implements IReceiveManager
                     UdpPermitToSendMsg msg;
                     {
                         SpinBlock block(resendInfoLock);
-                        msg.length = offsetof(UdpPermitToSendMsg, missingSequences) + missingCount*sizeof(msg.missingSequences[0]);
+                        msg.length = UdpPermitToSendMsg::messageFixedSize + missingCount*sizeof(msg.missingSequences[0]);
                         msg.cmd = flow_t::ok_to_send;
 
                         msg.destNodeIndex = myNodeIndex;