Lease enddate threshold

This commit is contained in:
orignal 2016-02-11 22:18:24 -05:00
parent ee8ab58d64
commit 517385fb63
2 changed files with 9 additions and 2 deletions

View File

@ -130,7 +130,7 @@ namespace data
leases += 4; // tunnel ID
lease.endDate = bufbe64toh (leases);
leases += 8; // end date
if (ts < lease.endDate)
if (ts < lease.endDate + LEASE_ENDDATE_THRESHOLD)
{
if (lease.endDate > m_ExpirationTime)
m_ExpirationTime = lease.endDate;
@ -151,7 +151,7 @@ namespace data
else
LogPrint (eLogWarning, "LeaseSet: Lease is expired already ");
}
if (!m_ExpirationTime)
if (!m_ExpirationTime && m_Leases.empty ())
{
LogPrint (eLogWarning, "LeaseSet: all leases are expired. Dropped");
m_IsValid = false;
@ -192,6 +192,12 @@ namespace data
if (ts < endDate)
leases.push_back (it);
}
if (leases.empty () && withThreshold)
{
for (auto it: m_Leases)
if (ts < it->endDate + LEASE_ENDDATE_THRESHOLD)
leases.push_back (it);
}
return leases;
}

View File

@ -17,6 +17,7 @@ namespace tunnel
namespace data
{
const int LEASE_ENDDATE_THRESHOLD = 9500; // in milliseconds
struct Lease
{
IdentHash tunnelGateway;