Merge pull request #621 from majestrate/master

double path build timeout from 15s to 30s
pull/622/head
Jeff 5 years ago committed by GitHub
commit 82491305dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -41,7 +41,8 @@ namespace llarp
r->netloop()) r->netloop())
, m_NetworkToUserPktQueue(nickname + "_recvq", r->netloop(), , m_NetworkToUserPktQueue(nickname + "_recvq", r->netloop(),
r->netloop()) r->netloop())
, m_Resolver(std::make_shared<dns::Proxy>(r->netloop(), r->logic(), r->netloop(), r->logic(), this)) , m_Resolver(std::make_shared< dns::Proxy >(
r->netloop(), r->logic(), r->netloop(), r->logic(), this))
{ {
#ifdef ANDROID #ifdef ANDROID
tunif.get_fd_promise = &get_tun_fd_promise; tunif.get_fd_promise = &get_tun_fd_promise;

@ -42,7 +42,7 @@ namespace llarp
/// default path lifetime in ms /// default path lifetime in ms
constexpr llarp_time_t default_lifetime = 10 * 60 * 1000; constexpr llarp_time_t default_lifetime = 10 * 60 * 1000;
/// after this many ms a path build times out /// after this many ms a path build times out
constexpr llarp_time_t build_timeout = 15000; constexpr llarp_time_t build_timeout = 30000;
/// measure latency every this interval ms /// measure latency every this interval ms
constexpr llarp_time_t latency_interval = 5000; constexpr llarp_time_t latency_interval = 5000;

@ -332,61 +332,33 @@ namespace llarp
OutboundContext::MarkCurrentIntroBad(llarp_time_t now) OutboundContext::MarkCurrentIntroBad(llarp_time_t now)
{ {
// insert bad intro // insert bad intro
m_BadIntros[remoteIntro] = now; m_BadIntros[m_NextIntro] = now;
// unconditional shift // try shifting intro without rebuild
bool shiftedRouter = false; if(ShiftIntroduction(false))
bool shiftedIntro = false;
// try same router
for(const auto& intro : currentIntroSet.I)
{
if(intro.ExpiresSoon(now))
continue;
if(router->routerProfiling().IsBadForPath(intro.router))
continue;
auto itr = m_BadIntros.find(intro);
if(itr == m_BadIntros.end() && intro.router == m_NextIntro.router)
{
if(intro.expiresAt > m_NextIntro.expiresAt)
{
shiftedIntro = true;
m_NextIntro = intro;
break;
}
}
}
if(!shiftedIntro)
{
// try any router
for(const auto& intro : currentIntroSet.I)
{
if(intro.ExpiresSoon(now))
continue;
auto itr = m_BadIntros.find(intro);
if(itr == m_BadIntros.end())
{
// TODO: this should always be true but idk if it really is
if(intro.expiresAt > m_NextIntro.expiresAt)
{
shiftedRouter = m_NextIntro.router != intro.router;
shiftedIntro = true;
m_NextIntro = intro;
break;
}
}
}
}
if(shiftedRouter)
{ {
lastShift = now; // we shifted
// check if we have a path to the next intro router
if(GetNewestPathByRouter(m_NextIntro.router))
return true;
// we don't have a path build one if we aren't building too fast
if(!BuildCooldownHit(now)) if(!BuildCooldownHit(now))
BuildOneAlignedTo(m_NextIntro.router); BuildOneAlignedTo(m_NextIntro.router);
return true;
} }
else if(!shiftedIntro) else
{ {
LogInfo(Name(), " updating introset"); // we didn't shift check if we should update introset
UpdateIntroSet(true); if(now - lastShift >= MIN_SHIFT_INTERVAL
|| currentIntroSet.HasExpiredIntros(now)
|| currentIntroSet.IsExpired(now))
{
// update introset
LogInfo(Name(), " updating introset");
UpdateIntroSet(true);
return true;
}
return false;
} }
return shiftedIntro;
} }
bool bool
@ -409,37 +381,40 @@ namespace llarp
{ {
if(intro.expiresAt > m_NextIntro.expiresAt) if(intro.expiresAt > m_NextIntro.expiresAt)
{ {
success = true;
m_NextIntro = intro; m_NextIntro = intro;
return true; return true;
} }
} }
} }
/// pick newer intro not on same router if(!success)
for(const auto& intro : currentIntroSet.I)
{ {
if(m_Endpoint->m_SnodeBlacklist.count(intro.router)) /// pick newer intro not on same router
continue; for(const auto& intro : currentIntroSet.I)
m_Endpoint->EnsureRouterIsKnown(intro.router);
if(intro.ExpiresSoon(now))
continue;
if(m_BadIntros.find(intro) == m_BadIntros.end() && m_NextIntro != intro)
{ {
if(intro.expiresAt > m_NextIntro.expiresAt) if(m_Endpoint->m_SnodeBlacklist.count(intro.router))
continue;
m_Endpoint->EnsureRouterIsKnown(intro.router);
if(intro.ExpiresSoon(now))
continue;
if(m_BadIntros.find(intro) == m_BadIntros.end()
&& m_NextIntro != intro)
{ {
shifted = intro.router != m_NextIntro.router; if(intro.expiresAt > m_NextIntro.expiresAt)
m_NextIntro = intro; {
success = true; shifted = intro.router != m_NextIntro.router;
m_NextIntro = intro;
success = true;
}
} }
} }
} }
if(m_NextIntro.router.IsZero()) if(m_NextIntro.router.IsZero())
return false; return false;
if(shifted) if(shifted)
{
lastShift = now; lastShift = now;
if(rebuild && !BuildCooldownHit(Now())) if(rebuild && !BuildCooldownHit(Now()))
BuildOneAlignedTo(m_NextIntro.router); BuildOneAlignedTo(m_NextIntro.router);
}
return success; return success;
} }
@ -496,7 +471,9 @@ namespace llarp
// check if we have a path to this router // check if we have a path to this router
num = 0; num = 0;
ForEachPath([&](const path::Path_ptr& p) { ForEachPath([&](const path::Path_ptr& p) {
if(p->Endpoint() == m_NextIntro.router) // don't count timed out paths
if(p->Status() != path::ePathTimeout
&& p->Endpoint() == m_NextIntro.router)
++num; ++num;
}); });
// build a path if one isn't already pending build or established // build a path if one isn't already pending build or established

Loading…
Cancel
Save