handover fixes

pull/1106/head
Jeff Becker 4 years ago
parent f7f5d893a5
commit e907d2ae19
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

@ -947,6 +947,18 @@ namespace llarp
return true;
}
void
Endpoint::MarkAddressOutbound(const Address& addr)
{
m_state->m_OutboundSessions.insert(addr);
}
bool
Endpoint::WantsOutboundSession(const Address& addr) const
{
return m_state->m_OutboundSessions.count(addr) > 0;
}
bool
Endpoint::EnsurePathToService(const Address remote, PathEnsureHook hook,
ABSL_ATTRIBUTE_UNUSED llarp_time_t timeoutMS)
@ -954,6 +966,8 @@ namespace llarp
static constexpr size_t NumParalellLookups = 2;
LogInfo(Name(), " Ensure Path to ", remote.ToString());
MarkAddressOutbound(remote);
auto& sessions = m_state->m_RemoteSessions;
{
@ -1193,8 +1207,7 @@ namespace llarp
}
}
}
// outbound converstation
else
{
auto& sessions = m_state->m_RemoteSessions;
auto range = sessions.equal_range(remote);
@ -1208,8 +1221,8 @@ namespace llarp
}
++itr;
}
// if there is an outbound context
if(range.first != sessions.end())
// if we want to make an outbound session
if(WantsOutboundSession(remote))
{
// add pending traffic
auto& traffic = m_state->m_PendingTraffic;

@ -197,11 +197,6 @@ namespace llarp
bool
HasPendingPathToService(const Address& remote) const;
/// return false if we don't have a path to the service
/// return true if we did and we removed it
bool
ForgetPathToService(const Address& remote);
bool
HandleDataMessage(path::Path_ptr path, const PathID_t from,
std::shared_ptr< ProtocolMessage > msg) override;
@ -253,8 +248,6 @@ namespace llarp
bool
SendTo(const ConvoTag tag, const llarp_buffer_t& pkt, ProtocolType t);
;
bool
HandleDataDrop(path::Path_ptr p, const PathID_t& dst, uint64_t s);
@ -263,6 +256,12 @@ namespace llarp
using PendingBufferQueue = std::deque< PendingBuffer >;
bool
WantsOutboundSession(const Address&) const override;
void
MarkAddressOutbound(const Address&) override;
bool
ShouldBundleRC() const override;

@ -95,6 +95,8 @@ namespace llarp
/// conversations
ConvoMap m_Sessions;
OutboundSessions_t m_OutboundSessions;
std::unordered_map< Tag, CachedTagResult, Tag::Hash > m_PrefetchedTags;
bool

@ -54,6 +54,9 @@ namespace llarp
using ConvoMap = std::unordered_map< ConvoTag, Session, ConvoTag::Hash >;
/// set of outbound addresses to maintain to
using OutboundSessions_t = std::unordered_set< Address, Address::Hash >;
using PathEnsureHook = std::function< void(Address, OutboundContext*) >;
} // namespace service

@ -72,6 +72,13 @@ namespace llarp
virtual bool
HasInboundConvo(const Address& addr) const = 0;
/// do we want a session outbound to addr
virtual bool
WantsOutboundSession(const Address& addr) const = 0;
virtual void
MarkAddressOutbound(const Address& addr) = 0;
virtual void
QueueRecvData(RecvDataEvent ev) = 0;
};

@ -278,6 +278,7 @@ namespace llarp
// check for expiration
if(remoteIntro.ExpiresSoon(now))
{
UpdateIntroSet();
// shift intro if it expires "soon"
if(ShiftIntroduction())
SwapIntros(); // swap intros if we shifted
@ -293,10 +294,6 @@ namespace llarp
else
++itr;
}
if(currentIntroSet.HasExpiredIntros(now))
{
UpdateIntroSet();
}
// send control message if we look too quiet
if(lastGoodSend)
{

Loading…
Cancel
Save