Jelajahi Sumber

HPCC-8390 Renaming to MsgHeader, using struct copy

Signed-off-by: Renato Golin <rengolin@hpccsystems.com>
Renato Golin 12 tahun lalu
induk
melakukan
a39de0108b
3 mengubah file dengan 38 tambahan dan 46 penghapusan
  1. 12 20
      roxie/udplib/udpsha.hpp
  2. 8 8
      roxie/udplib/udptrr.cpp
  3. 18 18
      roxie/udplib/udptrs.cpp

+ 12 - 20
roxie/udplib/udpsha.hpp

@@ -181,7 +181,7 @@ struct UdpPermitToSendMsg
 {
     // New static fields must be included inside this block, so that
     // size calculations work correctly
-    struct StaticBlock {
+    struct MsgHeader {
         unsigned short  length;
         unsigned short  cmd;
         unsigned short  destNodeIndex;
@@ -191,17 +191,17 @@ struct UdpPermitToSendMsg
 #ifdef CRC_MESSAGES
         unsigned        crc;
 #endif
-    } sb;
+    } hdr;
     // WARNING: Do not add any field below this line, if it must be included in the message
     unsigned        missingSequences[MAX_RESEND_TABLE_SIZE]; // only [missingCount] actually sent
 
     StringBuffer &toString(StringBuffer &str) const
     {
-        str.appendf("lastSeen=%u missingCount=%u", sb.lastSequenceSeen, sb.missingCount);
-        if (sb.missingCount)
+        str.appendf("lastSeen=%u missingCount=%u", hdr.lastSequenceSeen, hdr.missingCount);
+        if (hdr.missingCount)
         {
             str.append(" missing=");
-            for (unsigned j = 0; j < sb.missingCount; j++)
+            for (unsigned j = 0; j < hdr.missingCount; j++)
                 str.appendf(j?",%u":"%u", missingSequences[j]);
         }
         return str;
@@ -210,7 +210,7 @@ struct UdpPermitToSendMsg
 #ifdef CRC_MESSAGES
     unsigned calcCRC()
     {
-        size_t len = sizeof(StaticBlock) - sizeof(sb.crc);
+        size_t len = sizeof(MsgHeader) - sizeof(hdr.crc);
         unsigned expectedCRC = crc32((const char *) this, len, 0);
         if (missingCount)
             expectedCRC = crc32((const char *) &missingSequences, missingCount * sizeof(missingSequences[0]), expectedCRC); 
@@ -220,26 +220,18 @@ struct UdpPermitToSendMsg
 
     UdpPermitToSendMsg()
     {
-        sb.length = sb.cmd = sb.destNodeIndex = sb.max_data = 0;
-        sb.lastSequenceSeen = 0;
-        sb.missingCount = 0;
+        hdr.length = hdr.cmd = hdr.destNodeIndex = hdr.max_data = 0;
+        hdr.lastSequenceSeen = 0;
+        hdr.missingCount = 0;
 #ifdef CRC_MESSAGES
-        sb.crc = calcCRC();
+        hdr.crc = calcCRC();
 #endif
     }
 
     UdpPermitToSendMsg(const UdpPermitToSendMsg &from)
     {
-        sb.length = from.sb.length;
-        sb.cmd = from.sb.cmd;
-        sb.destNodeIndex = from.sb.destNodeIndex;
-        sb.max_data = from.sb.max_data;
-        sb.lastSequenceSeen = from.sb.lastSequenceSeen;
-        sb.missingCount = from.sb.missingCount;
-#ifdef CRC_MESSAGES
-        sb.crc = from.sb.crc;
-#endif
-        memcpy(missingSequences, from.missingSequences, from.sb.missingCount * sizeof(missingSequences[0]));
+        hdr = from.hdr;
+        memcpy(missingSequences, from.missingSequences, from.hdr.missingCount * sizeof(missingSequences[0]));
     }
 };
 

+ 8 - 8
roxie/udplib/udptrr.cpp

@@ -230,13 +230,13 @@ class CReceiveManager : public CInterface, implements IReceiveManager
                     UdpPermitToSendMsg msg;
                     {
                         SpinBlock block(resendInfoLock);
-                        msg.sb.length = sizeof(UdpPermitToSendMsg::StaticBlock) + missingCount*sizeof(msg.missingSequences[0]);
-                        msg.sb.cmd = flow_t::ok_to_send;
+                        msg.hdr.length = sizeof(UdpPermitToSendMsg::MsgHeader) + missingCount*sizeof(msg.missingSequences[0]);
+                        msg.hdr.cmd = flow_t::ok_to_send;
 
-                        msg.sb.destNodeIndex = myNodeIndex;
-                        msg.sb.max_data = maxTransfer;
-                        msg.sb.lastSequenceSeen = lastSeen;
-                        msg.sb.missingCount = missingCount;
+                        msg.hdr.destNodeIndex = myNodeIndex;
+                        msg.hdr.max_data = maxTransfer;
+                        msg.hdr.lastSequenceSeen = lastSeen;
+                        msg.hdr.missingCount = missingCount;
                         for (unsigned i = 0; i < missingCount; i++)
                         {
                             unsigned idx = (missingIndex + i) % missingTableSize;
@@ -245,7 +245,7 @@ class CReceiveManager : public CInterface, implements IReceiveManager
                                 DBGLOG("Requesting resend of packet %d", missing[idx]);
                         }
 #ifdef CRC_MESSAGES
-                        msg.sb.crc = msg.calcCRC();
+                        msg.hdr.crc = msg.calcCRC();
 #endif
                     }
                     if (checkTraceLevel(TRACE_RETRY_DATA, 5))
@@ -253,7 +253,7 @@ class CReceiveManager : public CInterface, implements IReceiveManager
                         StringBuffer s;
                         DBGLOG("requestToSend %s", msg.toString(s).str());
                     }
-                    flowSocket->write(&msg, msg.sb.length);
+                    flowSocket->write(&msg, msg.hdr.length);
                 }
                 catch(IException *e) 
                 {

+ 18 - 18
roxie/udplib/udptrs.cpp

@@ -123,13 +123,13 @@ public:
             permit.toString(permitStr);
             DBGLOG("UdpSender: cleanRetryData (%s), total %u available between %u and %u", permitStr.str(), retryDataCount, minUdpSequence, maxUdpSequence); 
         }
-        unsigned lastReceived = permit.sb.lastSequenceSeen;
+        unsigned lastReceived = permit.hdr.lastSequenceSeen;
         unsigned missingIndex = 0;
-        unsigned missingCount = permit.sb.missingCount;
+        unsigned missingCount = permit.hdr.missingCount;
         unsigned i = 0;
         if (maxRetryData)
         {
-            while (i < retryDataCount && retries.length() < permit.sb.max_data)
+            while (i < retryDataCount && retries.length() < permit.hdr.max_data)
             {
                 unsigned idx = (retryDataIdx + i) % maxRetryData;
                 DataBuffer *buffer = retryData[idx];
@@ -187,7 +187,7 @@ public:
     unsigned sendData(const UdpPermitToSendMsg &permit, bool isLocal, TokenBucket *bucket, bool &moreRequested, unsigned &maxPackets)
     {
         moreRequested = false;
-        maxPackets = permit.sb.max_data;
+        maxPackets = permit.hdr.max_data;
         PointerArray toSend;
         unsigned totalSent = cleanRetryData(permit, toSend);
         while (toSend.length() < maxPackets && dataQueued())
@@ -213,7 +213,7 @@ public:
             if (isRetry)
             {
                 if (checkTraceLevel(TRACE_RETRY_DATA, 1))
-                    DBGLOG("UdpSender: Resending packet to destination node %u sequence %u", permit.sb.destNodeIndex, header->udpSequence);
+                    DBGLOG("UdpSender: Resending packet to destination node %u sequence %u", permit.hdr.destNodeIndex, header->udpSequence);
                 atomic_inc(&packetsRetried);
             }
             else
@@ -264,7 +264,7 @@ public:
                 else
                 {
                     if (udpTraceLevel > 0)
-                        DBGLOG("Overflow in resend packet buffer for destination node %u - discarding packet sequence %u", permit.sb.destNodeIndex, header->udpSequence);
+                        DBGLOG("Overflow in resend packet buffer for destination node %u - discarding packet sequence %u", permit.hdr.destNodeIndex, header->udpSequence);
                     ::Release(retryData[slot]);
                 }
                 retryData[slot] = buffer;
@@ -948,20 +948,20 @@ class CSendManager : public CInterface, implements ISendManager
                     {
                         unsigned int res ;
                         flow_socket->read(&f, 1, sizeof(f), res, 5);
-                        assertex(res == f.sb.length);
+                        assertex(res == f.hdr.length);
 #ifdef CRC_MESSAGES
-                        assertex(f.sb.crc == f.calcCRC());
+                        assertex(f.hdr.crc == f.calcCRC());
 #endif
-                        switch (f.sb.cmd)
+                        switch (f.hdr.cmd)
                         {
                         case flow_t::ok_to_send:
                             if (udpTraceLevel > 1) 
-                                DBGLOG("UdpSender: received ok_to_send msg max %d packets from node=%u (length %u)", f.sb.max_data, f.sb.destNodeIndex, res);
+                                DBGLOG("UdpSender: received ok_to_send msg max %d packets from node=%u (length %u)", f.hdr.max_data, f.hdr.destNodeIndex, res);
                             parent.data->ok_to_send(f);
                             break;
 
                         default: 
-                            DBGLOG("UdpSender: received unknown flow message type=%d", f.sb.cmd);
+                            DBGLOG("UdpSender: received unknown flow message type=%d", f.hdr.cmd);
                         }
                     }
                     catch (IException *e) 
@@ -1060,7 +1060,7 @@ class CSendManager : public CInterface, implements ISendManager
                 return true;
             else 
             {
-                DBGLOG("UdpSender: push() failed - ignored ok_to_send msg - index=%u, maxData=%u", msg.sb.destNodeIndex, msg.sb.max_data);
+                DBGLOG("UdpSender: push() failed - ignored ok_to_send msg - index=%u, maxData=%u", msg.hdr.destNodeIndex, msg.hdr.max_data);
                 return false;
             }
         }
@@ -1081,19 +1081,19 @@ class CSendManager : public CInterface, implements ISendManager
 
                 if (udpSnifferEnabled)
                     send_sniff(true);
-                parent.send_flow->clear_to_send_received(permit.sb.destNodeIndex);
-                UdpReceiverEntry &receiverInfo = parent.receiversTable[permit.sb.destNodeIndex];
+                parent.send_flow->clear_to_send_received(permit.hdr.destNodeIndex);
+                UdpReceiverEntry &receiverInfo = parent.receiversTable[permit.hdr.destNodeIndex];
                 bool moreRequested;
                 unsigned maxPackets;
-                unsigned payload = receiverInfo.sendData(permit, (parent.myNodeIndex == permit.sb.destNodeIndex), bucket, moreRequested, maxPackets);
+                unsigned payload = receiverInfo.sendData(permit, (parent.myNodeIndex == permit.hdr.destNodeIndex), bucket, moreRequested, maxPackets);
                 if (udpSendCompletedInData && !maxPackets)
-                    parent.sendRequest(permit.sb.destNodeIndex, flow_t::send_completed);
-                parent.send_flow->send_done(permit.sb.destNodeIndex, moreRequested);
+                    parent.sendRequest(permit.hdr.destNodeIndex, flow_t::send_completed);
+                parent.send_flow->send_done(permit.hdr.destNodeIndex, moreRequested);
                 if (udpSnifferEnabled)
                     send_sniff(false);
                 
                 if (udpTraceLevel > 1) 
-                    DBGLOG("UdpSender: sent %u bytes to node=%d", payload, permit.sb.destNodeIndex);
+                    DBGLOG("UdpSender: sent %u bytes to node=%d", payload, permit.hdr.destNodeIndex);
                 
             }
             if (udpTraceLevel > 0)