handover fixes

pull/1106/head
Jeff Becker 5 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; 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 bool
Endpoint::EnsurePathToService(const Address remote, PathEnsureHook hook, Endpoint::EnsurePathToService(const Address remote, PathEnsureHook hook,
ABSL_ATTRIBUTE_UNUSED llarp_time_t timeoutMS) ABSL_ATTRIBUTE_UNUSED llarp_time_t timeoutMS)
@ -954,6 +966,8 @@ namespace llarp
static constexpr size_t NumParalellLookups = 2; static constexpr size_t NumParalellLookups = 2;
LogInfo(Name(), " Ensure Path to ", remote.ToString()); LogInfo(Name(), " Ensure Path to ", remote.ToString());
MarkAddressOutbound(remote);
auto& sessions = m_state->m_RemoteSessions; auto& sessions = m_state->m_RemoteSessions;
{ {
@ -1193,8 +1207,7 @@ namespace llarp
} }
} }
} }
else
// outbound converstation
{ {
auto& sessions = m_state->m_RemoteSessions; auto& sessions = m_state->m_RemoteSessions;
auto range = sessions.equal_range(remote); auto range = sessions.equal_range(remote);
@ -1208,8 +1221,8 @@ namespace llarp
} }
++itr; ++itr;
} }
// if there is an outbound context // if we want to make an outbound session
if(range.first != sessions.end()) if(WantsOutboundSession(remote))
{ {
// add pending traffic // add pending traffic
auto& traffic = m_state->m_PendingTraffic; auto& traffic = m_state->m_PendingTraffic;

@ -197,11 +197,6 @@ namespace llarp
bool bool
HasPendingPathToService(const Address& remote) const; 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 bool
HandleDataMessage(path::Path_ptr path, const PathID_t from, HandleDataMessage(path::Path_ptr path, const PathID_t from,
std::shared_ptr< ProtocolMessage > msg) override; std::shared_ptr< ProtocolMessage > msg) override;
@ -253,8 +248,6 @@ namespace llarp
bool bool
SendTo(const ConvoTag tag, const llarp_buffer_t& pkt, ProtocolType t); SendTo(const ConvoTag tag, const llarp_buffer_t& pkt, ProtocolType t);
;
bool bool
HandleDataDrop(path::Path_ptr p, const PathID_t& dst, uint64_t s); HandleDataDrop(path::Path_ptr p, const PathID_t& dst, uint64_t s);
@ -263,6 +256,12 @@ namespace llarp
using PendingBufferQueue = std::deque< PendingBuffer >; using PendingBufferQueue = std::deque< PendingBuffer >;
bool
WantsOutboundSession(const Address&) const override;
void
MarkAddressOutbound(const Address&) override;
bool bool
ShouldBundleRC() const override; ShouldBundleRC() const override;

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

@ -54,6 +54,9 @@ namespace llarp
using ConvoMap = std::unordered_map< ConvoTag, Session, ConvoTag::Hash >; 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*) >; using PathEnsureHook = std::function< void(Address, OutboundContext*) >;
} // namespace service } // namespace service

@ -72,6 +72,13 @@ namespace llarp
virtual bool virtual bool
HasInboundConvo(const Address& addr) const = 0; 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 virtual void
QueueRecvData(RecvDataEvent ev) = 0; QueueRecvData(RecvDataEvent ev) = 0;
}; };

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

Loading…
Cancel
Save