Browse Source

Lease enddate threshold

pull/378/head
orignal 9 years ago
parent
commit
517385fb63
  1. 10
      LeaseSet.cpp
  2. 1
      LeaseSet.h

10
LeaseSet.cpp

@ -130,7 +130,7 @@ namespace data @@ -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 @@ -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 @@ -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;
}

1
LeaseSet.h

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

Loading…
Cancel
Save