diff --git a/core/dtn7/src/core/application_agent.rs b/core/dtn7/src/core/application_agent.rs index 593e625e..d9a74ee4 100644 --- a/core/dtn7/src/core/application_agent.rs +++ b/core/dtn7/src/core/application_agent.rs @@ -1,12 +1,12 @@ use bp7::{Bundle, EndpointID}; use enum_dispatch::enum_dispatch; -use log::{debug, error, trace}; +use log::{debug, trace}; use std::collections::VecDeque; use std::fmt::Debug; use tokio::sync::mpsc::Sender; use crate::dtnd::ws::BundleDelivery; -use crate::store_remove; +use crate::store_remove_if_singleton_bundle; //use crate::dtnd::ws::WsAASession; #[enum_dispatch] @@ -47,7 +47,7 @@ impl ApplicationAgent for SimpleApplicationAgent { if addr.try_send(BundleDelivery(bundle.clone())).is_err() { self.bundles.push_back(bundle.clone()); } else { - remove_singleton_bundle_from_store(&bundle); + store_remove_if_singleton_bundle(bundle); } } else { // save in temp buffer for delivery @@ -57,7 +57,7 @@ impl ApplicationAgent for SimpleApplicationAgent { fn pop(&mut self) -> Option { let bundle = self.bundles.pop_front(); if let Some(bndl) = bundle.as_ref() { - remove_singleton_bundle_from_store(bndl); + store_remove_if_singleton_bundle(bndl); }; bundle } @@ -84,13 +84,3 @@ impl SimpleApplicationAgent { } } } - -/// Removes a bundle from the store if its destination is a singleton endpoint -fn remove_singleton_bundle_from_store(bundle: &Bundle) { - if !bundle.primary.destination.is_non_singleton() { - debug!("Removing bundle with singleton destination from store"); - if let Err(e) = store_remove(&bundle.id()) { - error!("Error while removing bundle from store: {:?}", e); - } - } -} diff --git a/core/dtn7/src/lib.rs b/core/dtn7/src/lib.rs index 9e91a45f..2d826fd8 100644 --- a/core/dtn7/src/lib.rs +++ b/core/dtn7/src/lib.rs @@ -188,6 +188,16 @@ pub fn store_remove(bid: &str) -> Result<()> { Ok(()) } +/// Removes a bundle from the store if its destination is a singleton endpoint +fn store_remove_if_singleton_bundle(bundle: &Bundle) { + if !bundle.primary.destination.is_non_singleton() { + debug!("Removing bundle with singleton destination from store"); + if let Err(e) = store_remove(&bundle.id()) { + error!("Error while removing bundle from store: {:?}", e); + } + } +} + pub fn store_update_metadata(bp: &BundlePack) -> Result<()> { (*STORE.lock()).update_metadata(bp) } diff --git a/tests/local_ping_echo.sh b/tests/local_ping_echo.sh index 0fc1436e..383153a2 100755 --- a/tests/local_ping_echo.sh +++ b/tests/local_ping_echo.sh @@ -21,14 +21,15 @@ $BINS/examples/dtnping -d 'dtn://node1/echo' -c 6 -t 500ms RC=$? echo "RET: $RC" -echo -n "Bundles in store on node 1: " NUM_BUNDLES=$($BINS/dtnquery bundles | grep "dtn://" | wc -l | awk '{print $1}') -echo -n $NUM_BUNDLES +NUM_DELETED=$($BINS/dtnquery store | grep -o "Deleted" | wc -l | awk '{print $1}') EXPECTED_BUNDLES=0 +EXPECTED_DELETED=12 -echo " / $EXPECTED_BUNDLES" -if [ "$NUM_BUNDLES" = "$EXPECTED_BUNDLES" ]; then +echo "Bundles in store on node 1: : $NUM_BUNDLES / $EXPECTED_BUNDLES" +echo "Bundles marked as Deleted in store on node 1: : $NUM_DELETED / $EXPECTED_DELETED" +if [ "$NUM_BUNDLES" = "$EXPECTED_BUNDLES" ] && [ "$NUM_DELETED" = "$EXPECTED_DELETED" ]; then echo "Correct number of bundles in store!" else echo "Incorrect number of bundles in store!"