face: Fix bug with removePendingInterest
Change-Id: I364c1441da2cc0042ba461bc3a6cb4b70e53b166
Refs: #1917
diff --git a/src/detail/pending-interest.hpp b/src/detail/pending-interest.hpp
index 791f59b..0a66dca 100644
--- a/src/detail/pending-interest.hpp
+++ b/src/detail/pending-interest.hpp
@@ -57,13 +57,13 @@
}
const shared_ptr<const Interest>&
- getInterest()
+ getInterest() const
{
return m_interest;
}
const OnData&
- getOnData()
+ getOnData() const
{
return m_onData;
}
@@ -73,7 +73,7 @@
* @return true if this interest timed out, otherwise false.
*/
bool
- isTimedOut(const time::steady_clock::TimePoint& now)
+ isTimedOut(const time::steady_clock::TimePoint& now) const
{
return now >= m_timeout;
}
@@ -82,7 +82,7 @@
* Call m_onTimeout (if defined). This ignores exceptions from the m_onTimeout.
*/
void
- callTimeout()
+ callTimeout() const
{
if (m_onTimeout) {
m_onTimeout(*m_interest);
@@ -114,7 +114,8 @@
bool
operator()(const shared_ptr<const PendingInterest>& pendingInterest) const
{
- return (reinterpret_cast<const PendingInterestId*>(pendingInterest.get()) == m_id);
+ return (reinterpret_cast<const PendingInterestId*>(
+ pendingInterest->getInterest().get()) == m_id);
}
private:
const PendingInterestId* m_id;
diff --git a/src/face.cpp b/src/face.cpp
index 79d8dc1..42fc522 100644
--- a/src/face.cpp
+++ b/src/face.cpp
@@ -193,6 +193,12 @@
m_ioService->post(bind(&Impl::asyncRemovePendingInterest, m_impl, pendingInterestId));
}
+size_t
+Face::getNPendingInterests() const
+{
+ return m_impl->m_pendingInterestTable.size();
+}
+
const RegisteredPrefixId*
Face::setInterestFilter(const InterestFilter& interestFilter,
const OnInterest& onInterest,
diff --git a/src/face.hpp b/src/face.hpp
index 974aa69..3407d92 100644
--- a/src/face.hpp
+++ b/src/face.hpp
@@ -225,6 +225,12 @@
removePendingInterest(const PendingInterestId* pendingInterestId);
/**
+ * @brief Get number of pending Interests
+ */
+ size_t
+ getNPendingInterests() const;
+
+ /**
* @brief Set InterestFilter to dispatch incoming matching interest to onInterest
* callback and register the filtered prefix with the connected NDN forwarder
*