mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-02-02 02:44:15 +00:00
cleand destination requests every 15 seconds
This commit is contained in:
parent
02c22b850b
commit
778d1afda0
25
NetDb.cpp
25
NetDb.cpp
@ -124,7 +124,7 @@ namespace data
|
|||||||
|
|
||||||
void NetDb::Run ()
|
void NetDb::Run ()
|
||||||
{
|
{
|
||||||
uint32_t lastSave = 0, lastPublish = 0, lastExploratory = 0;
|
uint32_t lastSave = 0, lastPublish = 0, lastExploratory = 0, lastManageRequest = 0;
|
||||||
while (m_IsRunning)
|
while (m_IsRunning)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -156,12 +156,14 @@ namespace data
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
if (!m_IsRunning) break;
|
if (!m_IsRunning) break;
|
||||||
ManageRequests ();
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t ts = i2p::util::GetSecondsSinceEpoch ();
|
uint64_t ts = i2p::util::GetSecondsSinceEpoch ();
|
||||||
|
if (ts - lastManageRequest >= 15) // manage requests every 15 seconds
|
||||||
|
{
|
||||||
|
ManageRequests ();
|
||||||
|
lastManageRequest = ts;
|
||||||
|
}
|
||||||
if (ts - lastSave >= 60) // save routers, manage leasesets and validate subscriptions every minute
|
if (ts - lastSave >= 60) // save routers, manage leasesets and validate subscriptions every minute
|
||||||
{
|
{
|
||||||
if (lastSave)
|
if (lastSave)
|
||||||
@ -183,7 +185,8 @@ namespace data
|
|||||||
{
|
{
|
||||||
numRouters = 800/numRouters;
|
numRouters = 800/numRouters;
|
||||||
if (numRouters < 1) numRouters = 1;
|
if (numRouters < 1) numRouters = 1;
|
||||||
if (numRouters > 9) numRouters = 9;
|
if (numRouters > 9) numRouters = 9;
|
||||||
|
ManageRequests ();
|
||||||
Explore (numRouters);
|
Explore (numRouters);
|
||||||
lastExploratory = ts;
|
lastExploratory = ts;
|
||||||
}
|
}
|
||||||
@ -976,16 +979,17 @@ namespace data
|
|||||||
void NetDb::ManageRequests ()
|
void NetDb::ManageRequests ()
|
||||||
{
|
{
|
||||||
uint64_t ts = i2p::util::GetSecondsSinceEpoch ();
|
uint64_t ts = i2p::util::GetSecondsSinceEpoch ();
|
||||||
|
std::unique_lock<std::mutex> l(m_RequestedDestinationsMutex);
|
||||||
for (auto it = m_RequestedDestinations.begin (); it != m_RequestedDestinations.end ();)
|
for (auto it = m_RequestedDestinations.begin (); it != m_RequestedDestinations.end ();)
|
||||||
{
|
{
|
||||||
auto dest = it->second;
|
auto dest = it->second;
|
||||||
bool done = false;
|
bool done = false;
|
||||||
if (!dest->IsExploratory () && ts < dest->GetCreationTime () + 60) // request is worthless after 1 minute
|
if (ts < dest->GetCreationTime () + 60) // request is worthless after 1 minute
|
||||||
{
|
{
|
||||||
if (ts > dest->GetCreationTime () + 5) // no response for 5 seconds
|
if (ts > dest->GetCreationTime () + 5) // no response for 5 seconds
|
||||||
{
|
{
|
||||||
auto count = dest->GetExcludedPeers ().size ();
|
auto count = dest->GetExcludedPeers ().size ();
|
||||||
if (count < 7)
|
if (!dest->IsExploratory () && count < 7)
|
||||||
{
|
{
|
||||||
auto pool = i2p::tunnel::tunnels.GetExploratoryPool ();
|
auto pool = i2p::tunnel::tunnels.GetExploratoryPool ();
|
||||||
auto outbound = pool->GetNextOutboundTunnel ();
|
auto outbound = pool->GetNextOutboundTunnel ();
|
||||||
@ -1004,17 +1008,18 @@ namespace data
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogPrint (eLogWarning, dest->GetDestination ().ToBase64 (), " not found after 7 attempts");
|
if (!dest->IsExploratory ())
|
||||||
|
LogPrint (eLogWarning, dest->GetDestination ().ToBase64 (), " not found after 7 attempts");
|
||||||
done = true;
|
done = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else // delete previous exploratory
|
else // delete obsolete request
|
||||||
done = true;
|
done = true;
|
||||||
|
|
||||||
if (done)
|
if (done)
|
||||||
{
|
{
|
||||||
delete it->second;
|
delete dest;
|
||||||
it = m_RequestedDestinations.erase (it);
|
it = m_RequestedDestinations.erase (it);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user