updated BPQBlock code - seg fault
authoraidan
Mon, 15 Aug 2011 13:42:11 +0100
changeset 37 6023dbd1cef5
parent 36 25401075f22b
child 38 e51218da06a2
updated BPQBlock code - seg fault
servlib/bundling/BPQBlock.cc
servlib/bundling/FragmentManager.cc
--- a/servlib/bundling/BPQBlock.cc	Mon Aug 15 12:35:59 2011 +0100
+++ b/servlib/bundling/BPQBlock.cc	Mon Aug 15 13:42:11 2011 +0100
@@ -211,11 +211,13 @@
     u_int len = block->data_length();
     log_debug_p(LOG, "BPQBlock::initialise: len = %u", len);
     u_int num_frags;
+    ASSERT ( block->data() != NULL );
     u_char* buf = block->data();
-    log_debug_p(LOG, "BPQBlock::initialise: buf = %s", buf);
+    //log_debug_p(LOG, "BPQBlock::initialise: buf = %s", buf);
 
     // BPQ-kind             1-byte
     if ( i < len ) {
+        ASSERT ( buf[i] == 0 || buf[i] == 1 );
         kind_ = (kind_t) buf[i++];
         log_debug_p(LOG, "BPQBlock::initialise: kind = %d", kind_);
     }
--- a/servlib/bundling/FragmentManager.cc	Mon Aug 15 12:35:59 2011 +0100
+++ b/servlib/bundling/FragmentManager.cc	Mon Aug 15 13:42:11 2011 +0100
@@ -434,14 +434,16 @@
                    fragment->frag_offset());
 
 
-    // XXX/lynch ensure that non-payload blocks are added to fragment bundle
-    // but only add one block of each type
+    // XXX/lynch ensure that extension blocks are added to the assembled bundle
+    // Only add each block type once
+    // And don't add primary / payload blocks (this is done elsewhere)
     BlockInfoVec::const_iterator block_i;
     for (block_i =  fragment->recv_blocks().begin();
          block_i != fragment->recv_blocks().end(); 
          ++block_i)
     {
         if ( !state->bundle()->recv_blocks().has_block( block_i->type() ) &&
+             block_i->type() != BundleProtocol::PRIMARY_BLOCK             && 
              block_i->type() != BundleProtocol::PAYLOAD_BLOCK ) {
 
             log_debug("Adding block(%d) to fragment bundle", block_i->type());