List:Commits« Previous MessageNext Message »
From:Frazer Clement Date:January 23 2013 5:59pm
Subject:bzr push into mysql-5.5-cluster-7.2 branch (frazer.clement:4157 to 4158)
View as plain text  
 4158 Frazer Clement	2013-01-23 [merge]
      Merge 7.1->7.2

    modified:
      storage/ndb/include/kernel/signaldata/PackedSignal.hpp
      storage/ndb/src/common/debugger/signaldata/PackedSignal.cpp
      storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp
      storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp
 4157 Mauritz Sundell	2013-01-22 [merge]
      merge 7.1 -> 7.2

    modified:
      storage/ndb/test/ndbapi/testDict.cpp
=== modified file 'storage/ndb/include/kernel/signaldata/PackedSignal.hpp'
--- a/storage/ndb/include/kernel/signaldata/PackedSignal.hpp	2011-07-05 12:46:07 +0000
+++ b/storage/ndb/include/kernel/signaldata/PackedSignal.hpp	2013-01-23 17:56:09 +0000
@@ -31,8 +31,24 @@
 #define ZFIRE_TRIG_REQ 6
 #define ZFIRE_TRIG_CONF 7
 
+// Definitions for verification of packed signals
+static const int VERIFY_PACKED_SEND = 1;
+#ifdef VM_TRACE
+static const int VERIFY_PACKED_RECEIVE = 1;
+#else
+static const int VERIFY_PACKED_RECEIVE = 0;
+#endif
+static const int LQH_RECEIVE_TYPES = ((1 << ZCOMMIT) + (1 << ZCOMPLETE) + 
+                                      (1 << ZLQHKEYCONF) + (1 << ZREMOVE_MARKER) +
+                                      (1 << ZFIRE_TRIG_REQ));
+static const int TC_RECEIVE_TYPES = ((1 << ZCOMMITTED) + (1 << ZCOMPLETED) +
+                                     (1 << ZLQHKEYCONF) + (1 << ZFIRE_TRIG_CONF));
+
 class PackedSignal {
+public:
+  static bool verify(const Uint32* data, Uint32 len, Uint32 typesExpected, Uint32 commitLen, Uint32 receiverBlockNo);
 
+private:
   static Uint32 getSignalType(Uint32 data);
 
   /**

=== modified file 'storage/ndb/src/common/debugger/signaldata/PackedSignal.cpp'
--- a/storage/ndb/src/common/debugger/signaldata/PackedSignal.cpp	2011-07-05 12:46:07 +0000
+++ b/storage/ndb/src/common/debugger/signaldata/PackedSignal.cpp	2013-01-23 17:56:09 +0000
@@ -18,6 +18,7 @@
 
 #include <signaldata/PackedSignal.hpp>
 #include <signaldata/LqhKey.hpp>
+#include <signaldata/FireTrigOrd.hpp>
 #include <debugger/DebuggerNames.hpp>
 
 bool
@@ -98,7 +99,7 @@ printPACKED_SIGNAL(FILE * output, const
       break;
     }
     case ZFIRE_TRIG_REQ: {
-      Uint32 signalLength = 3;
+      Uint32 signalLength = FireTrigReq::SignalLength;
 
       fprintf(output, "--------------- Signal ----------------\n");
       fprintf(output, "r.bn: %u \"%s\", length: %u \"FIRE_TRIG_REQ\"\n",
@@ -107,7 +108,7 @@ printPACKED_SIGNAL(FILE * output, const
       break;
     }
     case ZFIRE_TRIG_CONF: {
-      Uint32 signalLength = 4;
+      Uint32 signalLength = FireTrigConf::SignalLength;
 
       fprintf(output, "--------------- Signal ----------------\n");
       fprintf(output, "r.bn: %u \"%s\", length: %u \"FIRE_TRIG_CONF\"\n",
@@ -124,3 +125,80 @@ printPACKED_SIGNAL(FILE * output, const
   fprintf(output, "--------- End Packed Signals ----------\n");
   return true;
 }
+
+bool
+PackedSignal::verify(const Uint32* data, Uint32 len, Uint32 receiverBlockNo, 
+                     Uint32 typesExpected, Uint32 commitLen)
+{
+  Uint32 pos = 0;
+  bool bad = false;
+
+  if (unlikely(len > 25))
+  {
+    fprintf(stderr, "Bad PackedSignal length : %u\n", len);
+    bad = true;
+  }
+  else
+  {
+    while ((pos < len) && ! bad)
+    {
+      Uint32 sigType = data[pos] >> 28;
+      if (unlikely(((1 << sigType) & typesExpected) == 0))
+      {
+        fprintf(stderr, "Unexpected sigtype in packed signal : %u at pos %u.  Expected : %u\n",
+                sigType, pos, typesExpected);
+        bad = true;
+        break;
+      }
+      switch (sigType)
+      {
+      case ZCOMMIT:
+        assert(commitLen > 0);
+        pos += commitLen;
+        break;
+      case ZCOMPLETE:
+        pos+= 3;
+        break;
+      case ZCOMMITTED:
+        pos+= 3;
+        break;
+      case ZCOMPLETED:
+        pos+= 3;
+        break;
+      case ZLQHKEYCONF:
+        pos+= LqhKeyConf::SignalLength;
+        break;
+      case ZREMOVE_MARKER:
+        pos+= 3;
+        break;
+      case ZFIRE_TRIG_REQ:
+        pos+= FireTrigReq::SignalLength;
+        break;
+      case ZFIRE_TRIG_CONF:
+        pos+= FireTrigConf::SignalLength;
+        break;
+      default :
+        fprintf(stderr, "Unrecognised signal type %u at pos %u\n",
+                sigType, pos);
+        bad = true;
+        break;
+      }
+    }
+    
+    if (likely(pos == len))
+    {
+      /* Looks ok */
+      return true;
+    }
+    
+    if (!bad)
+    {
+      fprintf(stderr, "Packed signal component length (%u) != total length (%u)\n",
+               pos, len);
+    }
+  }
+
+  printPACKED_SIGNAL(stderr, data, len, receiverBlockNo);
+  
+  return false;
+}

=== modified file 'storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp'
--- a/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp	2012-12-03 09:49:51 +0000
+++ b/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp	2013-01-23 17:56:09 +0000
@@ -3348,6 +3348,16 @@ void Dblqh::execPACKED_SIGNAL(Signal* si
 
   ndbrequire(Tlength <= 25);
   MEMCOPY_NO_WORDS(&TpackedData[0], &signal->theData[0], Tlength);
+
+  if (VERIFY_PACKED_RECEIVE)
+  {
+    ndbrequire(PackedSignal::verify(&TpackedData[0], 
+                                    Tlength, 
+                                    cownref,
+                                    LQH_RECEIVE_TYPES, 
+                                    TcommitLen));
+  }
+
   while (Tlength > Tstep) {
     switch (TpackedData[Tstep] >> 28) {
     case ZCOMMIT:
@@ -3746,6 +3756,17 @@ void Dblqh::sendPackedSignal(Signal* sig
   MEMCOPY_NO_WORDS(&signal->theData[0],
                    &container->packedWords[0],
                    noOfWords);
+  if (VERIFY_PACKED_SEND)
+  {
+    int receiveTypes = (refToMain(hostRef) == DBLQH)?
+      LQH_RECEIVE_TYPES:
+      TC_RECEIVE_TYPES;
+    ndbrequire(PackedSignal::verify(&signal->theData[0],
+                                    noOfWords,
+                                    hostRef,
+                                    receiveTypes,
+                                    5)); /* Commit signal length */
+  }
   sendSignal(hostRef, GSN_PACKED_SIGNAL, signal, noOfWords, JBB);
 }
 

=== modified file 'storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp'
--- a/storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp	2012-11-20 19:29:20 +0000
+++ b/storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp	2013-01-23 17:56:09 +0000
@@ -4075,6 +4075,15 @@ void Dbtc::execPACKED_SIGNAL(Signal* sig
     TpackDataPtr[2] = Tdata3;
     TpackDataPtr[3] = Tdata4;
   }//for
+
+  if (VERIFY_PACKED_RECEIVE)
+  {
+    ndbrequire(PackedSignal::verify(&TpackedData[0],
+                                    Tlength,
+                                    cownref,
+                                    TC_RECEIVE_TYPES,
+                                    0)); /* Irrelevant */
+  }
   while (Tlength > Tstep) {
 
     TpackDataPtr = &TpackedData[Tstep];
@@ -4960,6 +4969,15 @@ void Dbtc::sendPackedSignal(Signal* sign
   ndbassert(TnoOfWords <= 25);
   container->noOfPackedWords = 0;
   memcpy(&signal->theData[0], &container->packedWords[0], 4 * TnoOfWords);
+  if (VERIFY_PACKED_SEND)
+  {
+    ndbrequire(refToMain(container->hostBlockRef) == DBLQH);
+    ndbrequire(PackedSignal::verify(&signal->theData[0],
+                                    TnoOfWords,
+                                    container->hostBlockRef,
+                                    LQH_RECEIVE_TYPES,
+                                    5)); /* Commit signal length */
+  }
   sendSignal(container->hostBlockRef,
              GSN_PACKED_SIGNAL,
              signal,

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-5.5-cluster-7.2 branch (frazer.clement:4157 to 4158) Frazer Clement11 Mar