servlib/bundling/BundleDaemon.cc
changeset 66 e1101c5d54a1
parent 64 1296a0283271
child 67 cfe2328ba1c6
equal deleted inserted replaced
65:333724f2f7cf 66:e1101c5d54a1
   921             return;
   921             return;
   922         }
   922         }
   923 
   923 
   924     }
   924     }
   925 
   925 
   926     // try to handle a BPQ block
   926     if ( bpq_cache_->cache_enabled_ ) {
   927     if ( event->source_ == EVENTSRC_APP   || 
   927     	// try to handle a BPQ block
   928          event->source_ == EVENTSRC_PEER  || 
   928     	if ( event->source_ == EVENTSRC_APP   ||
   929          event->source_ == EVENTSRC_STORE ||
   929 			 event->source_ == EVENTSRC_PEER  ||
   930          event->source_ == EVENTSRC_FRAGMENTATION) {
   930 			 event->source_ == EVENTSRC_STORE ||
   931 
   931 			 event->source_ == EVENTSRC_FRAGMENTATION) {
   932 		handle_bpq_block(bundle, event);
   932 
   933 
   933 			handle_bpq_block(bundle, event);
       
   934 		}
   934     }
   935     }
   935 
   936 
   936     // If the bundle contains a BPQ query that was successfully answered
   937     // If the bundle contains a BPQ query that was successfully answered
   937     // a response has already been sent and the query deleted
   938     // a response has already been sent and the query deleted
   938     // so return from this function
   939     // so return from this function
  2688             event->daemon_only_ = true;
  2689             event->daemon_only_ = true;
  2689         }
  2690         }
  2690 
  2691 
  2691     } else if (bpq_block.kind() == BPQBlock::KIND_RESPONSE) {
  2692     } else if (bpq_block.kind() == BPQBlock::KIND_RESPONSE) {
  2692     	// don't accept local responses
  2693     	// don't accept local responses
  2693     	if (!local_bundle &&
  2694     	if (!local_bundle) {
  2694     		!bundle->is_fragment()	) {//TODO: remove this temp frag exclusion
       
  2695 
  2695 
  2696     		if (bpq_cache()->add_response_bundle(bundle, &bpq_block) &&
  2696     		if (bpq_cache()->add_response_bundle(bundle, &bpq_block) &&
  2697     			event->source_ != EVENTSRC_STORE) {
  2697     			event->source_ != EVENTSRC_STORE) {
  2698 
  2698 
  2699     			bundle->set_in_datastore(true);
  2699     			bundle->set_in_datastore(true);
  2700 				actions_->store_add(bundle);
  2700 				actions_->store_add(bundle);
  2701     		}
  2701     		}
  2702     	}
  2702     	}
       
  2703 
  2703     } else if (bpq_block.kind() == BPQBlock::KIND_RESPONSE_DO_NOT_CACHE_FRAG) {
  2704     } else if (bpq_block.kind() == BPQBlock::KIND_RESPONSE_DO_NOT_CACHE_FRAG) {
  2704 
       
  2705     	// don't accept local responses
  2705     	// don't accept local responses
  2706     	if (!local_bundle &&
  2706     	if (!local_bundle &&
  2707     		!bundle->is_fragment()	) {
  2707     		!bundle->is_fragment()	) {
  2708 
  2708 
  2709     		if (bpq_cache()->add_response_bundle(bundle, &bpq_block) &&
  2709     		if (bpq_cache()->add_response_bundle(bundle, &bpq_block) &&
  2712     			bundle->set_in_datastore(true);
  2712     			bundle->set_in_datastore(true);
  2713 				actions_->store_add(bundle);
  2713 				actions_->store_add(bundle);
  2714     		}
  2714     		}
  2715     	}
  2715     	}
  2716 
  2716 
  2717 
       
  2718     	log_info_p("/dtn/daemon/bpq", "Query: %s answered completely");
       
  2719     } else {
  2717     } else {
  2720         log_err_p("/dtn/daemon/bpq", "ERROR - BPQ Block: invalid kind %d", 
  2718         log_err_p("/dtn/daemon/bpq", "ERROR - BPQ Block: invalid kind %d", 
  2721             bpq_block.kind());
  2719             bpq_block.kind());
  2722         NOTREACHED;
  2720         NOTREACHED;
  2723         return false; 
  2721         return false;