servlib/bundling/BPQBlockProcessor.cc
changeset 47 f1d80668861b
parent 45 208a44ac3a5e
child 48 40c9ff70865a
--- a/servlib/bundling/BPQBlockProcessor.cc	Tue Aug 16 16:08:39 2011 +0100
+++ b/servlib/bundling/BPQBlockProcessor.cc	Thu Aug 18 11:30:52 2011 +0100
@@ -46,11 +46,6 @@
 {
     log_info_p(LOG, "BPQBlockProcessor::consume() start");
 
-    (void)bundle;
-//    (void)block;
-//    (void)buf;
-//    (void)len;
-
     int cc;
 
     if ( (cc = BlockProcessor::consume(bundle, block, buf, len)) < 0) {
@@ -90,17 +85,35 @@
 {
     log_info_p(LOG, "BPQBlockProcessor::prepare()");
 
+    (void)link;
+    (void)list; 
+
+
+    // Received blocks are added to the end of the list (which
+    // maintains the order they arrived in) but API blocks 
+    // are added after the primary block (that is, before the
+    // payload and the received blocks). This places them "outside"
+    // the original blocks.
+
     if ( (const_cast<Bundle*>(bundle))->api_blocks()->
             has_block(BundleProtocol::QUERY_EXTENSION_BLOCK) ) {
 
         log_info_p(LOG, "BPQBlock found in API Block Vec => created locally");
-        return BlockProcessor::prepare(bundle, xmit_blocks, source, link, list);
+
+        ASSERT((*xmit_blocks)[0].type() == BundleProtocol::PRIMARY_BLOCK);
+        xmit_blocks->insert(xmit_blocks->begin() + 1, BlockInfo(this, source));
+
+        return BP_SUCCESS;
 
     } else if ( (const_cast<Bundle*>(bundle))->recv_blocks().
                 has_block(BundleProtocol::QUERY_EXTENSION_BLOCK) ) {
 
         log_info_p(LOG, "BPQBlock found in Recv Block Vec => created remotly");
-        return BlockProcessor::prepare(bundle, xmit_blocks, source, link, list);
+
+        xmit_blocks->append_block(this, source);
+
+        return BP_SUCCESS;
+
 
     } else {