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())
, m_NetworkToUserPktQueue(nickname + "_recvq", 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
tunif.get_fd_promise = &get_tun_fd_promise;

@ -42,7 +42,7 @@ namespace llarp
/// default path lifetime in ms
constexpr llarp_time_t default_lifetime = 10 * 60 * 1000;
/// 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
constexpr llarp_time_t latency_interval = 5000;

@ -332,61 +332,33 @@ namespace llarp
OutboundContext::MarkCurrentIntroBad(llarp_time_t now)
{
// insert bad intro
m_BadIntros[remoteIntro] = now;
// unconditional shift
bool shiftedRouter = 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())
m_BadIntros[m_NextIntro] = now;
// try shifting intro without rebuild
if(ShiftIntroduction(false))
{
// 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))
BuildOneAlignedTo(m_NextIntro.router);
return true;
}
else if(!shiftedIntro)
else
{
// we didn't shift check if we should update introset
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
@ -409,11 +381,14 @@ namespace llarp
{
if(intro.expiresAt > m_NextIntro.expiresAt)
{
success = true;
m_NextIntro = intro;
return true;
}
}
}
if(!success)
{
/// pick newer intro not on same router
for(const auto& intro : currentIntroSet.I)
{
@ -422,7 +397,8 @@ namespace llarp
m_Endpoint->EnsureRouterIsKnown(intro.router);
if(intro.ExpiresSoon(now))
continue;
if(m_BadIntros.find(intro) == m_BadIntros.end() && m_NextIntro != intro)
if(m_BadIntros.find(intro) == m_BadIntros.end()
&& m_NextIntro != intro)
{
if(intro.expiresAt > m_NextIntro.expiresAt)
{
@ -432,14 +408,13 @@ namespace llarp
}
}
}
}
if(m_NextIntro.router.IsZero())
return false;
if(shifted)
{
lastShift = now;
if(rebuild && !BuildCooldownHit(Now()))
BuildOneAlignedTo(m_NextIntro.router);
}
return success;
}
@ -496,7 +471,9 @@ namespace llarp
// check if we have a path to this router
num = 0;
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;
});
// build a path if one isn't already pending build or established

Loading…
Cancel
Save