fw: incoming Data pipeline avoid sending to inFace
refs #1556
Change-Id: I1e38e3142f9c6536180f2aa494d7e2032ad76c2d
diff --git a/daemon/fw/forwarder.cpp b/daemon/fw/forwarder.cpp
index 2f20b5c..4d0deeb 100644
--- a/daemon/fw/forwarder.cpp
+++ b/daemon/fw/forwarder.cpp
@@ -274,8 +274,12 @@
// foreach pending downstream
for (std::set<shared_ptr<Face> >::iterator it = pendingDownstreams.begin();
it != pendingDownstreams.end(); ++it) {
+ shared_ptr<Face> pendingDownstream = *it;
+ if (pendingDownstream.get() == &inFace) {
+ continue;
+ }
// goto outgoing Data pipeline
- this->onOutgoingData(data, **it);
+ this->onOutgoingData(data, *pendingDownstream);
}
}
diff --git a/tests/daemon/fw/forwarder.cpp b/tests/daemon/fw/forwarder.cpp
index 0b72a0d..3a20033 100644
--- a/tests/daemon/fw/forwarder.cpp
+++ b/tests/daemon/fw/forwarder.cpp
@@ -346,6 +346,40 @@
BOOST_CHECK_EQUAL(strategyQ->m_beforeExpirePendingInterest_count, 0);
}
+BOOST_AUTO_TEST_CASE(IncomingData)
+{
+ LimitedIo limitedIo;
+ Forwarder forwarder;
+ shared_ptr<DummyFace> face1 = make_shared<DummyFace>();
+ shared_ptr<DummyFace> face2 = make_shared<DummyFace>();
+ shared_ptr<DummyFace> face3 = make_shared<DummyFace>();
+ shared_ptr<DummyFace> face4 = make_shared<DummyFace>();
+ forwarder.addFace(face1);
+ forwarder.addFace(face2);
+
+ Pit& pit = forwarder.getPit();
+ shared_ptr<Interest> interest0 = makeInterest("ndn:/");
+ shared_ptr<pit::Entry> pit0 = pit.insert(*interest0).first;
+ pit0->insertOrUpdateInRecord(face1, *interest0);
+ shared_ptr<Interest> interestA = makeInterest("ndn:/A");
+ shared_ptr<pit::Entry> pitA = pit.insert(*interestA).first;
+ pitA->insertOrUpdateInRecord(face1, *interestA);
+ pitA->insertOrUpdateInRecord(face2, *interestA);
+ shared_ptr<Interest> interestC = makeInterest("ndn:/A/B/C");
+ shared_ptr<pit::Entry> pitC = pit.insert(*interestC).first;
+ pitC->insertOrUpdateInRecord(face3, *interestC);
+ pitC->insertOrUpdateInRecord(face4, *interestC);
+
+ shared_ptr<Data> dataD = makeData("ndn:/A/B/C/D");
+ forwarder.onIncomingData(*face3, *dataD);
+ limitedIo.run(LimitedIo::UNLIMITED_OPS, time::milliseconds(5));
+
+ BOOST_CHECK_EQUAL(face1->m_sentDatas.size(), 1);
+ BOOST_CHECK_EQUAL(face2->m_sentDatas.size(), 1);
+ BOOST_CHECK_EQUAL(face3->m_sentDatas.size(), 0);
+ BOOST_CHECK_EQUAL(face4->m_sentDatas.size(), 1);
+}
+
BOOST_AUTO_TEST_SUITE_END()
} // namespace tests