included orig_length in bundle copy and fixed bpq handler in daemon
authoraidan
Thu, 13 Oct 2011 10:58:18 +0100
changeset 60 64954ed8a0a1
parent 59 e5674a26ce74
child 61 166a3782491c
included orig_length in bundle copy and fixed bpq handler in daemon
servlib/bundling/BPQCache.cc
servlib/bundling/BPQResponse.cc
servlib/bundling/BundleDaemon.cc
--- a/servlib/bundling/BPQCache.cc	Thu Oct 06 18:06:34 2011 +0100
+++ b/servlib/bundling/BPQCache.cc	Thu Oct 13 10:58:18 2011 +0100
@@ -123,6 +123,8 @@
 										 current_fragment,
 										 local_eid);
 
+		ASSERT(new_response->is_fragment() == current_fragment->is_fragment());
+
 		BundleReceivedEvent* e = new BundleReceivedEvent(new_response, EVENTSRC_CACHE);
 		BundleDaemon::instance()->post(e);
 
--- a/servlib/bundling/BPQResponse.cc	Thu Oct 06 18:06:34 2011 +0100
+++ b/servlib/bundling/BPQResponse.cc	Thu Oct 13 10:58:18 2011 +0100
@@ -40,6 +40,10 @@
     // init metadata
     cached_response->copy_metadata(new_response);
 
+    // include info not copied over in prev function
+    new_response->set_orig_length(cached_response->orig_length());
+    new_response->set_frag_offset(cached_response->frag_offset());
+
     // set EIDs
     new_response->mutable_source()->assign(local_eid);
     new_response->mutable_dest()->assign(query->replyto());
--- a/servlib/bundling/BundleDaemon.cc	Thu Oct 06 18:06:34 2011 +0100
+++ b/servlib/bundling/BundleDaemon.cc	Thu Oct 13 10:58:18 2011 +0100
@@ -929,10 +929,8 @@
          event->source_ == EVENTSRC_STORE ||
          event->source_ == EVENTSRC_FRAGMENTATION) {
 
-        // TODO: change this to allow fragment responses be sent
-//        if ( ! bundle->is_fragment() ) {
 		handle_bpq_block(bundle, event);
-//        }
+
     }
 
     // If the bundle contains a BPQ query that was successfully answered
@@ -2633,6 +2631,8 @@
     		if (bundle->recv_blocks().has_block(BundleProtocol::QUERY_EXTENSION_BLOCK)) {
     			block = bundle->recv_blocks().
     			                find_block(BundleProtocol::QUERY_EXTENSION_BLOCK);
+    		} else {
+    			return false;
     		}
     		break;
 
@@ -2640,19 +2640,12 @@
     		if (bundle->api_blocks()->has_block(BundleProtocol::QUERY_EXTENSION_BLOCK)) {
 				block = bundle->api_blocks()->
     		                	find_block(BundleProtocol::QUERY_EXTENSION_BLOCK);
+    		} else {
+    			return false;
     		}
     		break;
 
     	case EVENTSRC_STORE:
-    		if (bundle->in_bpq_cache()) {
-    			log_info_p("/dtn/daemon/bpq", "handle_bpq_block: cache bundle from STORE");
-    			BPQBlock bpq_block(bundle);
-    			bpq_cache()->answer_query(bundle, &bpq_block);
-//    			accept_bpq_response(bundle, &bpq_block, false);
-    			return true;
-    		}
-    		break;
-
     	case EVENTSRC_FRAGMENTATION:
     		if (bundle->recv_blocks().has_block(BundleProtocol::QUERY_EXTENSION_BLOCK)) {
 				block = bundle->recv_blocks().
@@ -2661,6 +2654,8 @@
     		else if (bundle->api_blocks()->has_block(BundleProtocol::QUERY_EXTENSION_BLOCK)) {
 				block = bundle->api_blocks()->
     		                	find_block(BundleProtocol::QUERY_EXTENSION_BLOCK);
+    		} else {
+    			return false;
     		}
     		break;