more logic for dead sessions to prevent segfault

pull/18/head
Jeff Becker 6 years ago
parent 16508a99db
commit b273676a63
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

@ -193,6 +193,7 @@ namespace llarp
llarp_time_t createdAt; llarp_time_t createdAt;
llarp_time_t sendTimeout = 20 * 1000; llarp_time_t sendTimeout = 20 * 1000;
llarp_time_t connectTimeout = 30 * 1000; llarp_time_t connectTimeout = 30 * 1000;
bool markedBad = false;
virtual void virtual void
ShiftIntroduction(){}; ShiftIntroduction(){};
@ -237,6 +238,9 @@ namespace llarp
bool bool
MarkCurrentIntroBad(llarp_time_t now); MarkCurrentIntroBad(llarp_time_t now);
bool
ShouldBuildMore() const;
/// tick internal state /// tick internal state
/// return true to mark as dead /// return true to mark as dead
bool bool

@ -225,9 +225,10 @@ namespace llarp
{ {
if(itr->second->Tick(now)) if(itr->second->Tick(now))
{ {
m_DeadSessions.insert( m_DeadSessions
std::make_pair(itr->first, std::move(itr->second))); .insert(std::make_pair(itr->first, std::move(itr->second)))
itr = m_RemoteSessions.erase(itr); ->second->markedBad = true;
itr = m_RemoteSessions.erase(itr);
} }
else else
++itr; ++itr;
@ -783,6 +784,9 @@ namespace llarp
void void
Endpoint::OutboundContext::HandlePathBuilt(path::Path* p) Endpoint::OutboundContext::HandlePathBuilt(path::Path* p)
{ {
/// don't use it if we are marked bad
if(markedBad)
return;
p->SetDataHandler( p->SetDataHandler(
std::bind(&Endpoint::OutboundContext::HandleHiddenServiceFrame, this, std::bind(&Endpoint::OutboundContext::HandleHiddenServiceFrame, this,
std::placeholders::_1, std::placeholders::_2)); std::placeholders::_1, std::placeholders::_2));
@ -899,7 +903,9 @@ namespace llarp
Endpoint::OutboundContext::OnIntroSetUpdate(const Address& addr, Endpoint::OutboundContext::OnIntroSetUpdate(const Address& addr,
const IntroSet* i) const IntroSet* i)
{ {
if(i) if(markedBad)
return true;
if(i && currentIntroSet.T < i->T)
{ {
currentIntroSet = *i; currentIntroSet = *i;
ShiftIntroduction(); ShiftIntroduction();
@ -1008,7 +1014,7 @@ namespace llarp
} }
m_PendingTraffic[remote].emplace(data, t); m_PendingTraffic[remote].emplace(data, t);
return true; return true;
} // namespace service }
bool bool
Endpoint::OutboundContext::MarkCurrentIntroBad(llarp_time_t now) Endpoint::OutboundContext::MarkCurrentIntroBad(llarp_time_t now)
@ -1226,7 +1232,7 @@ namespace llarp
void void
Endpoint::OutboundContext::UpdateIntroSet() Endpoint::OutboundContext::UpdateIntroSet()
{ {
if(updatingIntroSet) if(updatingIntroSet || markedBad)
return; return;
auto addr = currentIntroSet.A.Addr(); auto addr = currentIntroSet.A.Addr();
auto path = m_Endpoint->GetEstablishedPathClosestTo(addr.data()); auto path = m_Endpoint->GetEstablishedPathClosestTo(addr.data());
@ -1309,6 +1315,14 @@ namespace llarp
return ++(itr->second.seqno); return ++(itr->second.seqno);
} }
bool
Endpoint::OutboundContext::ShouldBuildMore() const
{
if(markedBad)
return false;
return path::Builder::ShouldBuildMore();
}
/// send on an established convo tag /// send on an established convo tag
void void
Endpoint::SendContext::EncryptAndSendTo(llarp_buffer_t payload, Endpoint::SendContext::EncryptAndSendTo(llarp_buffer_t payload,

Loading…
Cancel
Save