# HG changeset patch # User aidan # Date 1313663452 -3600 # Node ID f1d80668861bd8cd1497d4fb26b3163a4303ce73 # Parent 5832202f8a44963660494e0bd8c279afa5f738c9 moved BPQ block prepair code from BlockProcessor to BPQBlockProcessor diff -r 5832202f8a44 -r f1d80668861b servlib/bundling/BPQBlockProcessor.cc --- 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))->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))->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 { diff -r 5832202f8a44 -r f1d80668861b servlib/bundling/BundleProtocol.cc --- a/servlib/bundling/BundleProtocol.cc Tue Aug 16 16:08:39 2011 +0100 +++ b/servlib/bundling/BundleProtocol.cc Thu Aug 18 11:30:52 2011 +0100 @@ -168,11 +168,12 @@ continue; } - if (! xmit_blocks->has_block(i) && - i != BundleProtocol::QUERY_EXTENSION_BLOCK) { + if (! xmit_blocks->has_block(i)) { + if (i == BundleProtocol::QUERY_EXTENSION_BLOCK) log_debug_p(LOG, "adding extra BPQ block!!!"); - bp->prepare(bundle, xmit_blocks, NULL, link, BlockInfo::LIST_NONE); + else + bp->prepare(bundle, xmit_blocks, NULL, link, BlockInfo::LIST_NONE); } }