[ndnSIM] fw: Add beforeSatisfyInterest and beforeExpirePendingInterest signals
The beforeExpirePendingInterest signal, in addition to actually timed out
interests, also includes NACKed interests.
Change-Id: I01b3a6e9f6090673c864d29065fd6d182fc251c4
diff --git a/daemon/fw/forwarder.cpp b/daemon/fw/forwarder.cpp
index c9a3fb8..2a36e57 100644
--- a/daemon/fw/forwarder.cpp
+++ b/daemon/fw/forwarder.cpp
@@ -33,6 +33,8 @@
#include <ndn-cxx/lp/tags.hpp>
+#include "face/null-face.hpp"
+
namespace nfd {
NFD_LOG_INIT(Forwarder);
@@ -49,7 +51,10 @@
, m_pit(m_nameTree)
, m_measurements(m_nameTree)
, m_strategyChoice(*this)
+ , m_csFace(face::makeNullFace(FaceUri("contentstore://")))
{
+ getFaceTable().addReserved(m_csFace, face::FACEID_CONTENT_STORE);
+
m_faceTable.afterAdd.connect([this] (Face& face) {
face.afterReceiveInterest.connect(
[this, &face] (const Interest& interest) {
@@ -229,6 +234,10 @@
// set PIT expiry timer to now
this->setExpiryTimer(pitEntry, 0_ms);
+ beforeSatisfyInterest(*pitEntry, *m_csFace, data);
+ this->dispatchToStrategy(*pitEntry,
+ [&] (fw::Strategy& strategy) { strategy.beforeSatisfyInterest(pitEntry, *m_csFace, data); });
+
// dispatch to strategy: after Content Store hit
this->dispatchToStrategy(*pitEntry,
[&] (fw::Strategy& strategy) { strategy.afterContentStoreHit(pitEntry, inFace, data); });
@@ -254,6 +263,10 @@
NFD_LOG_DEBUG("onInterestFinalize interest=" << pitEntry->getName() <<
(pitEntry->isSatisfied ? " satisfied" : " unsatisfied"));
+ if (!pitEntry->isSatisfied) {
+ beforeExpirePendingInterest(*pitEntry);
+ }
+
// Dead Nonce List insert if necessary
this->insertDeadNonceList(*pitEntry, 0);
@@ -311,6 +324,7 @@
// set PIT expiry timer to now
this->setExpiryTimer(pitEntry, 0_ms);
+ beforeSatisfyInterest(*pitEntry, inFace, data);
// trigger strategy: after receive Data
this->dispatchToStrategy(*pitEntry,
[&] (fw::Strategy& strategy) { strategy.afterReceiveData(pitEntry, inFace, data); });
@@ -345,6 +359,7 @@
this->setExpiryTimer(pitEntry, 0_ms);
// invoke PIT satisfy callback
+ beforeSatisfyInterest(*pitEntry, inFace, data);
this->dispatchToStrategy(*pitEntry,
[&] (fw::Strategy& strategy) { strategy.beforeSatisfyInterest(pitEntry, inFace, data); });