Fixed the block copy issue, there is still an assertion that is failing in the primary block processor
authoraidan
Tue, 31 May 2011 17:35:55 +0100
changeset 7 0a3c1a78bf75
parent 6 d1f220643814
child 8 ce3cb8a86959
Fixed the block copy issue, there is still an assertion that is failing in the primary block processor
servlib/bundling/BPQResponse.cc
servlib/bundling/BundleDaemon.cc
--- a/servlib/bundling/BPQResponse.cc	Mon May 30 19:36:18 2011 +0100
+++ b/servlib/bundling/BPQResponse.cc	Tue May 31 17:35:55 2011 +0100
@@ -59,12 +59,23 @@
          iter != api_blocks->end();
          ++iter)
     {
-        BlockInfo current = *iter;    
+        BlockInfo current_bi = *iter;    
+        BlockProcessor* new_bp = BundleProtocol::find_processor(
+                                    current_bi.owner()->block_type());
 
+        BlockInfo* new_bi = new_response->api_blocks()->append_block(new_bp);
+        new_bp->init_block( new_bi,
+                            new_response->api_blocks(),
+                            current_bi.type(),
+                            current_bi.flags(),
+                            (const u_char*)current_bi.data(),
+                            current_bi.full_length() );
+/*
         BlockInfo* new_bi = new BlockInfo(current);
         new_bi->set_flag(current.flags());
 
         new_response->api_blocks()->append_block(current.owner(), new_bi);
+*/
     }
 
     // copy RECV blocks
@@ -74,8 +85,20 @@
          iter != recv_blocks->end();
          ++iter)
     {
-        BlockInfo current = *iter;       
+        BlockInfo current_bi = *iter;       
+        BlockProcessor* new_bp = BundleProtocol::find_processor(
+                                    current_bi.owner()->block_type());
 
+        BlockInfo* new_bi = new_response->api_blocks()->append_block(new_bp);
+        new_bp->init_block( new_bi,
+                            new_response->mutable_recv_blocks(),
+                            current_bi.type(),
+                            current_bi.flags(),
+                            (const u_char*)current_bi.data(),
+                            current_bi.data_length() );
+
+
+/*
         BlockInfo* new_bi = new BlockInfo(current);
         new_bi->set_flag(current.flags());
 
@@ -85,8 +108,10 @@
             log_debug_p(LOG, "_COPY_  kind(%d) query_len(%d) query(%s)",
                      bpq.kind(), bpq.query_len(), bpq.query_val());
         }
+*/
     }
     
+//   new_response->xmit_blocks()
    return true;
 }
 
--- a/servlib/bundling/BundleDaemon.cc	Mon May 30 19:36:18 2011 +0100
+++ b/servlib/bundling/BundleDaemon.cc	Tue May 31 17:35:55 2011 +0100
@@ -414,7 +414,7 @@
                    (char*)current_bpq.query_val());
 
         if ( bpq_block->match(&current_bpq) ) {
-            log_info("_BPQ_M MATCH SUCCESSFUL");
+            log_info("_BPQ_M MATCH SUCCESSFUL - remove & add");
             bpq_bundles_->erase(current_bundle);
             break;
         } 
@@ -477,7 +477,7 @@
                    (char*)current_bpq.query_val());
 
         if ( bpq_block->match(&current_bpq) ) {
-            log_info("_BPQ_M MATCH SUCCESSFUL");
+            log_info("_BPQ_M MATCH SUCCESSFUL - answer");
 
             Bundle* response = new Bundle();
             BPQResponse::create_bpq_response(response,
@@ -499,7 +499,7 @@
         }
     }
 
-    log_info("_BPQ_ No response was found for the BPQ query *%p", bpq_block);
+    log_info("_BPQ_ No response was found for the BPQ query");
     return false;
 }
 
@@ -515,6 +515,16 @@
          iter != bpq_bundles_->end();
          ++iter)
     {
+/*
+        Bundle* bundle = *iter;
+        if (log_enabled(oasys::LOG_DEBUG)) {
+            oasys::StaticStringBuffer<1024> buf;
+            buf.appendf("_CACHE_ BUNDLE\n");
+            bundle->format_verbose(&buf);
+            log_multiline(oasys::LOG_DEBUG, buf.c_str());
+        }
+*/
+
         Bundle* current_bundle = *iter;
 
         if ( (! current_bundle->recv_blocks().
@@ -527,9 +537,11 @@
 
         BPQBlock bpq(current_bundle);
         log_debug("_CACHE_ (%d) kind(%d) query_len(%d) query(%s)",
-                    i, bpq.kind(), bpq.query_len(), bpq.query_val());
+                    i+1, bpq.kind(), bpq.query_len(), bpq.query_val());
         i++;
     }
+    if ( i==0 )
+        log_debug("_CACHE_ empty");
 }
 
 
@@ -1130,9 +1142,9 @@
     log_debug("trying to delete xmit blocks for bundle id:%d on link %s",
               bundle->bundleid(),link->name());
 
-    if ( ! bpq_bundles_->contains(bundle) ) {
+//    if ( ! bpq_bundles_->contains(bundle) ) {
         BundleProtocol::delete_blocks(bundle, link);
-    }
+//    }
 
     blocks = NULL;
 
@@ -2625,6 +2637,8 @@
      */
     if (bpq_block.kind() == BPQBlock::KIND_QUERY) {
         if (answer_bpq_query(bundle, &bpq_block)) {
+//HACK...
+            BundleProtocol::delete_blocks(bundle, event->link_); 
             event->daemon_only_ = true;
         }