From 7ba30eec25c9643cb805a05ce7c0fd9bb758cfdf Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Wed, 11 Mar 2020 16:55:12 -0400 Subject: [PATCH] squash commits --- llarp/link/link_manager.cpp | 10 ++++------ llarp/link/server.cpp | 12 ++++++++++++ llarp/link/server.hpp | 3 --- llarp/net/net_addr.cpp | 10 ++++++---- 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/llarp/link/link_manager.cpp b/llarp/link/link_manager.cpp index 8790b12b7e..df375a8c6f 100644 --- a/llarp/link/link_manager.cpp +++ b/llarp/link/link_manager.cpp @@ -146,11 +146,10 @@ namespace llarp return; util::Lock l(_mutex); - - m_PersistingSessions[remote] = - std::max(until, m_PersistingSessions[remote]); - LogDebug("persist session to ", remote, " until ", - m_PersistingSessions[remote].count()); + auto &curr = m_PersistingSessions[remote]; + if(until > curr) + curr = until; + LogDebug("persist session to ", remote, " until ", curr - time_now_ms()); } void @@ -307,7 +306,6 @@ namespace llarp auto link = GetLinkWithSessionTo(itr->first); if(link) { - LogDebug("keepalive to ", itr->first); link->KeepAliveSessionTo(itr->first); } else diff --git a/llarp/link/server.cpp b/llarp/link/server.cpp index 9e67a3ab6c..b8550dbb0e 100644 --- a/llarp/link/server.cpp +++ b/llarp/link/server.cpp @@ -267,7 +267,11 @@ namespace llarp { Lock_t l(m_AuthedLinksMutex); if(m_AuthedLinks.count(rc.pubkey) >= MaxSessionsPerKey) + { + LogDebug("Too many links to ", RouterID{rc.pubkey}, + ", not establishing another one"); return false; + } } llarp::AddressInfo to; if(!PickAddress(rc, to)) @@ -276,7 +280,12 @@ namespace llarp { Lock_t l(m_PendingMutex); if(m_Pending.count(addr) >= MaxSessionsPerKey) + { + LogDebug("Too many pending connections to ", addr, + " while establishing to ", RouterID{rc.pubkey}, + ", not establishing another"); return false; + } } std::shared_ptr< ILinkSession > s = NewOutboundSession(rc, to); if(PutSession(s)) @@ -385,7 +394,10 @@ namespace llarp while(itr != range.second) { if(itr->second->ShouldPing()) + { + LogDebug("keepalive to ", remote); itr->second->SendKeepAlive(); + } ++itr; } } diff --git a/llarp/link/server.hpp b/llarp/link/server.hpp index c46d14899a..733cbaf047 100644 --- a/llarp/link/server.hpp +++ b/llarp/link/server.hpp @@ -69,9 +69,6 @@ namespace llarp bool HasSessionTo(const RouterID& pk); - bool - HasSessionVia(const Addr& addr); - void ForEachSession(std::function< void(const ILinkSession*) > visit, bool randomize = false) const EXCLUDES(m_AuthedLinksMutex); diff --git a/llarp/net/net_addr.cpp b/llarp/net/net_addr.cpp index d4a9a4df5b..31660af45e 100644 --- a/llarp/net/net_addr.cpp +++ b/llarp/net/net_addr.cpp @@ -379,11 +379,13 @@ namespace llarp bool Addr::operator==(const Addr& other) const { - if(af() == AF_INET && other.af() == AF_INET) - return port() == other.port() && addr4()->s_addr == other.addr4()->s_addr; + if(af() != other.af() || port() != other.port()) + return false; - return af() == other.af() && memcmp(addr6(), other.addr6(), 16) == 0 - && port() == other.port(); + if(af() == AF_INET) + return addr4()->s_addr == other.addr4()->s_addr; + + return memcmp(addr6(), other.addr6(), 16) == 0; } Addr&