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

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

Loading…
Cancel
Save