limit link sessions to max of 16

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

@ -86,6 +86,7 @@ namespace llarp
void
ILinkLayer::MapAddr(const PubKey& pk, ILinkSession* s)
{
static constexpr size_t MaxSessionsPerKey = 16;
Lock l_authed(m_AuthedLinksMutex);
Lock l_pending(m_PendingMutex);
auto itr = m_Pending.begin();
@ -93,7 +94,10 @@ namespace llarp
{
if(itr->get() == s)
{
m_AuthedLinks.insert(std::make_pair(pk, std::move(*itr)));
if(m_AuthedLinks.count(pk) < MaxSessionsPerKey)
m_AuthedLinks.insert(std::make_pair(pk, std::move(*itr)));
else
s->Close();
itr = m_Pending.erase(itr);
return;
}

Loading…
Cancel
Save