diff --git a/llarp/iwp/linklayer.cpp b/llarp/iwp/linklayer.cpp index 907259b6b..bac509b60 100644 --- a/llarp/iwp/linklayer.cpp +++ b/llarp/iwp/linklayer.cpp @@ -20,34 +20,6 @@ namespace llarp LinkLayer::~LinkLayer() = default; - void - LinkLayer::Pump() - { - std::unordered_set< RouterID, RouterID::Hash > sessions; - { - ACQUIRE_LOCK(Lock_t l, m_AuthedLinksMutex); - auto itr = m_AuthedLinks.begin(); - while(itr != m_AuthedLinks.end()) - { - const RouterID r{itr->first}; - sessions.emplace(r); - ++itr; - } - } - ILinkLayer::Pump(); - { - ACQUIRE_LOCK(Lock_t l, m_AuthedLinksMutex); - for(const auto& pk : sessions) - { - if(m_AuthedLinks.count(pk) == 0) - { - // all sessions were removed - SessionClosed(pk); - } - } - } - } - const char* LinkLayer::Name() const { diff --git a/llarp/iwp/linklayer.hpp b/llarp/iwp/linklayer.hpp index 615917dda..a64f65eae 100644 --- a/llarp/iwp/linklayer.hpp +++ b/llarp/iwp/linklayer.hpp @@ -26,9 +26,6 @@ namespace llarp NewOutboundSession(const RouterContact &rc, const AddressInfo &ai) override; - void - Pump() override; - bool KeyGen(SecretKey &k) override; diff --git a/llarp/link/server.cpp b/llarp/link/server.cpp index 87f7a0f33..dbdb1bcd0 100644 --- a/llarp/link/server.cpp +++ b/llarp/link/server.cpp @@ -3,6 +3,7 @@ #include #include #include +#include namespace llarp { @@ -125,6 +126,7 @@ namespace llarp void ILinkLayer::Pump() { + std::unordered_set< RouterID, RouterID::Hash > closedSessions; auto _now = Now(); { ACQUIRE_LOCK(Lock_t l, m_AuthedLinksMutex); @@ -141,6 +143,7 @@ namespace llarp llarp::LogInfo("session to ", RouterID(itr->second->GetPubKey()), " timed out"); itr->second->Close(); + closedSessions.emplace(itr->first); itr = m_AuthedLinks.erase(itr); } } @@ -169,6 +172,16 @@ namespace llarp } } } + { + ACQUIRE_LOCK(Lock_t l, m_AuthedLinksMutex); + for(const auto& r : closedSessions) + { + if(m_AuthedLinks.count(r) == 0) + { + SessionClosed(r); + } + } + } } bool