model: Fixing limit borrowing bug in PerOutFaceLimit and PerFibLimit
When the application sends an Interest, router will borrow limit after
forwarding the Interest. If Data gets dropped in the middle, the
application will retransmit the Interest, and router will borrow another
limit. When Data comes back, limit is only returned once. This may cause
the limit to be wasted.
http://redmine.named-data.net/projects/ndnsim refs #1001
GitHub Issues refs #37
diff --git a/model/fw/per-fib-limits.h b/model/fw/per-fib-limits.h
index 6a18f13..633bd5e 100644
--- a/model/fw/per-fib-limits.h
+++ b/model/fw/per-fib-limits.h
@@ -169,7 +169,14 @@
NS_LOG_FUNCTION (this << pitEntry->GetPrefix ());
Ptr<Limits> fibLimits = pitEntry->GetFibEntry ()->template GetObject<Limits> ();
- fibLimits->ReturnLimit ();
+
+ for (pit::Entry::out_container::iterator face = pitEntry->GetOutgoing ().begin ();
+ face != pitEntry->GetOutgoing ().end ();
+ face ++)
+ {
+ for (uint32_t i = 0; i <= face->m_retxCount; i++)
+ fibLimits->ReturnLimit ();
+ }
super::WillEraseTimedOutPendingInterest (pitEntry);
}
@@ -183,7 +190,14 @@
NS_LOG_FUNCTION (this << pitEntry->GetPrefix ());
Ptr<Limits> fibLimits = pitEntry->GetFibEntry ()->template GetObject<Limits> ();
- fibLimits->ReturnLimit ();
+
+ for (pit::Entry::out_container::iterator face = pitEntry->GetOutgoing ().begin ();
+ face != pitEntry->GetOutgoing ().end ();
+ face ++)
+ {
+ for (uint32_t i = 0; i <= face->m_retxCount; i++)
+ fibLimits->ReturnLimit ();
+ }
super::WillSatisfyPendingInterest (inFace, pitEntry);
}
diff --git a/model/fw/per-out-face-limits.h b/model/fw/per-out-face-limits.h
index 2929b5b..8182d9a 100644
--- a/model/fw/per-out-face-limits.h
+++ b/model/fw/per-out-face-limits.h
@@ -164,7 +164,8 @@
face ++)
{
Ptr<Limits> faceLimits = face->m_face->GetObject<Limits> ();
- faceLimits->ReturnLimit ();
+ for (uint32_t i = 0; i <= face->m_retxCount; i++)
+ faceLimits->ReturnLimit ();
}
super::WillEraseTimedOutPendingInterest (pitEntry);
@@ -183,7 +184,8 @@
face ++)
{
Ptr<Limits> faceLimits = face->m_face->GetObject<Limits> ();
- faceLimits->ReturnLimit ();
+ for (uint32_t i = 0; i <= face->m_retxCount; i++)
+ faceLimits->ReturnLimit ();
}
super::WillSatisfyPendingInterest (inFace, pitEntry);