Adding boost logging support for NLSR
diff --git a/src/nlsr_lsdb.cpp b/src/nlsr_lsdb.cpp
index 9e3ffe7..de1343a 100644
--- a/src/nlsr_lsdb.cpp
+++ b/src/nlsr_lsdb.cpp
@@ -5,6 +5,12 @@
using namespace std;
+void
+Lsdb::cancelScheduleLsaExpiringEvent(nlsr& pnlsr, EventId eid)
+{
+ pnlsr.getScheduler().cancelEvent(eid);
+}
+
static bool
nameLsaCompareByKey(NameLsa& nlsa1, string& key){
return nlsa1.getNameLsaKey()==key;
@@ -42,10 +48,10 @@
}
-void
+ndn::EventId
Lsdb::scheduleNameLsaExpiration(nlsr& pnlsr, string key, int seqNo, int expTime)
{
- pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(expTime),
+ return pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(expTime),
ndn::bind(&Lsdb::exprireOrRefreshNameLsa,
this,boost::ref(pnlsr), key, seqNo));
}
@@ -76,8 +82,8 @@
{
timeToExpire=nlsa.getLifeTime();
}
- scheduleNameLsaExpiration( pnlsr, nlsa.getNameLsaKey(),
- nlsa.getLsSeqNo(), timeToExpire);
+ nlsa.setLsaExpiringEventId(scheduleNameLsaExpiration( pnlsr,
+ nlsa.getNameLsaKey(), nlsa.getLsSeqNo(), timeToExpire));
}
else
{
@@ -131,8 +137,10 @@
{
timeToExpire=nlsa.getLifeTime();
}
- scheduleNameLsaExpiration( pnlsr, nlsa.getNameLsaKey(),
- nlsa.getLsSeqNo(), timeToExpire);
+ cancelScheduleLsaExpiringEvent(pnlsr,
+ chkNameLsa.first.getLsaExpiringEventId());
+ chkNameLsa.first.setLsaExpiringEventId(scheduleNameLsaExpiration( pnlsr,
+ nlsa.getNameLsaKey(), nlsa.getLsSeqNo(), timeToExpire));
}
}
@@ -242,10 +250,10 @@
return std::make_pair(boost::ref(clsa),false);
}
-void
+ndn::EventId
Lsdb::scheduleCorLsaExpiration(nlsr& pnlsr, string key, int seqNo, int expTime)
{
- pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(expTime),
+ return pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(expTime),
ndn::bind(&Lsdb::exprireOrRefreshCorLsa,
this,boost::ref(pnlsr),key,seqNo));
}
@@ -298,8 +306,11 @@
{
timeToExpire=clsa.getLifeTime();
}
- scheduleCorLsaExpiration(pnlsr,clsa.getCorLsaKey(),
- clsa.getLsSeqNo(), timeToExpire);
+ cancelScheduleLsaExpiringEvent(pnlsr,
+ chkCorLsa.first.getLsaExpiringEventId());
+ chkCorLsa.first.setLsaExpiringEventId(scheduleCorLsaExpiration(pnlsr,
+ clsa.getCorLsaKey(),
+ clsa.getLsSeqNo(), timeToExpire));
}
}
@@ -444,10 +455,10 @@
-void
+ndn::EventId
Lsdb::scheduleAdjLsaExpiration(nlsr& pnlsr, string key, int seqNo, int expTime)
{
- pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(expTime),
+ return pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(expTime),
ndn::bind(&Lsdb::exprireOrRefreshAdjLsa,
this,boost::ref(pnlsr),key,seqNo));
}
@@ -489,8 +500,10 @@
{
timeToExpire=alsa.getLifeTime();
}
- scheduleAdjLsaExpiration(pnlsr,alsa.getAdjLsaKey(),
- alsa.getLsSeqNo(),timeToExpire);
+ cancelScheduleLsaExpiringEvent(pnlsr,
+ chkAdjLsa.first.getLsaExpiringEventId());
+ chkAdjLsa.first.setLsaExpiringEventId(scheduleAdjLsaExpiration(pnlsr,
+ alsa.getAdjLsaKey(), alsa.getLsSeqNo(),timeToExpire));
}
}