servlib/bundling/BundleDaemon.cc
changeset 24 ef7aa9ea3837
parent 22 3c36683e13be
child 25 082e0ad22355
--- a/servlib/bundling/BundleDaemon.cc	Thu Jun 30 14:28:19 2011 +0100
+++ b/servlib/bundling/BundleDaemon.cc	Thu Jun 30 14:29:54 2011 +0100
@@ -464,8 +464,8 @@
 bool
 BundleDaemon::add_bundle_to_bpq_cache(Bundle* bundle, bool add_to_store)
 {
-    const u_int64_t max_cache_size = 1073741824 * 10; // 10GB
-    //const u_int64_t max_cache_size = 5254027 * 3; 
+    //const u_int64_t max_cache_size = 1073741824 * 15; // 15GB
+    const u_int64_t max_cache_size = 5254027 * 3; 
 
     log_debug_p("/dtn/daemon/bpq","add_bundle_to_bpq_cache: *%p", bundle);
 
@@ -498,12 +498,11 @@
         cache_size -= front->payload().length();
         log_debug_p("/dtn/daemon/bpq","removing oldest bundle *%p of size: %llu "
                     "from cache to free space", bundle, front->payload().length());
-//        cache_size -= bpq_bundles_->front().object()->payload().length();
         bpq_bundles_->erase(bpq_bundles_->front());        
     }
 
     log_debug_p("/dtn/daemon/bpq","adding bundle *%p to cache", bundle);
-
+    
     bpq_bundles_->push_back(bundle);
     bundle->set_in_bpq_cache(true);
 
@@ -512,6 +511,9 @@
         actions_->store_add(bundle);
     }
 
+    cache_size += bundle_size;
+    log_debug_p("/dtn/daemon/bpq","The cache is now at %4.2f percent",
+                (double)cache_size/(double)max_cache_size);
     return true;
 }
 
@@ -543,6 +545,9 @@
                                              current_bundle,
                                              local_eid_);
 
+            BPQBlock foo(response);
+            ASSERT ( foo.kind() == BPQBlock::KIND_RESPONSE );
+
             BundleReceivedEvent e(response, EVENTSRC_CACHE);
             handle_event(&e);