limit number of concurrent dht lookups from dns to 4

pull/285/head
Jeff Becker 5 years ago
parent f84256d554
commit 90e45a810a
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

@ -966,14 +966,13 @@ namespace llarp
llarp::LogError(Name(), " failed to lookup ", addr.ToString(), " from ",
endpoint);
m_ServiceLookupFails[endpoint] = m_ServiceLookupFails[endpoint] + 1;
auto range = m_PendingServiceLookups.equal_range(addr);
auto itr = range.first;
if(itr != range.second)
// inform one
auto itr = m_PendingServiceLookups.find(addr);
if(itr != m_PendingServiceLookups.end())
{
itr->second(addr, nullptr);
++itr;
m_PendingServiceLookups.erase(itr);
}
m_PendingServiceLookups.erase(addr);
return false;
}
else
@ -1007,6 +1006,14 @@ namespace llarp
return true;
}
}
if(m_PendingServiceLookups.count(remote) >= MaxConcurrentLookups)
{
llarp::LogWarn(Name(), " has too many pending service lookups for ",
remote.ToString());
return false;
}
{
RouterID endpoint = path->Endpoint();
auto itr = m_ServiceLookupFails.find(endpoint);

@ -18,6 +18,8 @@ namespace llarp
{
struct ILookupHolder;
constexpr size_t MaxConcurrentLookups = size_t(4);
struct IServiceLookup
{
IServiceLookup() = delete;

Loading…
Cancel
Save