Repair bug in CcnxPit regarding timed out records pruning (sequential
index doesn't work anymore, because lifetime of entries can change)
diff --git a/model/ccnx-pit.cc b/model/ccnx-pit.cc
index e9c1f1b..e72c5e5 100644
--- a/model/ccnx-pit.cc
+++ b/model/ccnx-pit.cc
@@ -112,13 +112,14 @@
NS_LOG_LOGIC ("Cleaning PIT. Total: " << size ());
Time now = Simulator::Now ();
- uint32_t count = 0;
+ // uint32_t count = 0;
while (!empty ())
{
- if (get<i_timestamp> ().front ().GetExpireTime () <= now) // is the record stale?
+ CcnxPit::index<i_timestamp>::type::iterator entry = get<i_timestamp> ().begin ();
+ if (entry->GetExpireTime () <= now) // is the record stale?
{
- get<i_timestamp> ().pop_front ();
- count ++;
+ get<i_timestamp> ().erase (entry);
+ // count ++;
}
else
break; // nothing else to do. All later records will not be stale
diff --git a/model/ccnx-pit.h b/model/ccnx-pit.h
index 2fbafaa..565026a 100644
--- a/model/ccnx-pit.h
+++ b/model/ccnx-pit.h
@@ -35,7 +35,6 @@
#include <boost/multi_index/hashed_index.hpp>
#include <boost/multi_index/member.hpp>
#include <boost/multi_index/mem_fun.hpp>
-#include <boost/multi_index/sequenced_index.hpp>
#include <map>
#include <iostream>
#include <algorithm>
@@ -83,8 +82,10 @@
CcnxPrefixHash
>,
// sequenced to implement MRU
- boost::multi_index::sequenced<
- boost::multi_index::tag<__ccnx_private::i_timestamp> >
+ boost::multi_index::ordered_non_unique<
+ boost::multi_index::tag<__ccnx_private::i_timestamp>,
+ boost::multi_index::member<CcnxPitEntry, Time, &CcnxPitEntry::m_expireTime>
+ >
>
> type;
};