mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2024-11-16 00:12:43 +00:00
Lease enddate threshold
This commit is contained in:
parent
ee8ab58d64
commit
517385fb63
10
LeaseSet.cpp
10
LeaseSet.cpp
@ -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;
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,7 @@ namespace tunnel
|
||||
|
||||
namespace data
|
||||
{
|
||||
const int LEASE_ENDDATE_THRESHOLD = 9500; // in milliseconds
|
||||
struct Lease
|
||||
{
|
||||
IdentHash tunnelGateway;
|
||||
|
Loading…
Reference in New Issue
Block a user