call path build fail stuff in logic thread

pull/747/head
Jeff Becker 5 years ago
parent b4af87aa42
commit aa0a795689
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

@ -106,7 +106,7 @@ namespace llarp
Path::HandleLRSM(uint64_t status, std::array< EncryptedFrame, 8 >& frames,
AbstractRouter* r)
{
uint64_t currentStatus = LR_StatusRecord::SUCCESS;
uint64_t currentStatus = status;
size_t index = 0;
while(index < hops.size())
@ -143,7 +143,7 @@ namespace llarp
++index;
}
if((currentStatus & LR_StatusRecord::SUCCESS) == 1)
if(currentStatus & LR_StatusRecord::SUCCESS)
{
llarp::LogDebug("LR_Status message processed, path build successful");
auto self = shared_from_this();
@ -153,7 +153,7 @@ namespace llarp
{
r->routerProfiling().MarkPathFail(this);
llarp::LogInfo("LR_Status message processed, path build failed");
llarp::LogDebug("LR_Status message processed, path build failed");
if(currentStatus & LR_StatusRecord::FAIL_TIMEOUT)
{
@ -197,8 +197,9 @@ namespace llarp
{
llarp::LogDebug("Path build failed for an unspecified reason");
}
EnterState(ePathFailed, r->Now());
auto self = shared_from_this();
r->logic()->queue_func(
[=]() { self->EnterState(ePathFailed, r->Now()); });
}
// TODO: meaningful return value?
@ -211,6 +212,8 @@ namespace llarp
if(st == ePathFailed)
{
_status = st;
m_PathSet->HandlePathBuildFailed(shared_from_this());
return;
}
else if(st == ePathExpired && _status == ePathBuilding)
{

@ -442,15 +442,29 @@ namespace llarp
}
void
Builder::HandlePathBuildTimeout(Path_ptr p)
Builder::HandlePathBuildFailed(Path_ptr p)
{
router->routerProfiling().MarkPathFail(p.get());
PathSet::HandlePathBuildFailed(p);
DoPathBuildBackoff();
}
void
Builder::DoPathBuildBackoff()
{
// linear backoff
static constexpr llarp_time_t MaxBuildInterval = 30 * 1000;
buildIntervalLimit = std::min(
MIN_PATH_BUILD_INTERVAL + buildIntervalLimit, MaxBuildInterval);
LogWarn(Name(), " build interval is now ", buildIntervalLimit);
}
void
Builder::HandlePathBuildTimeout(Path_ptr p)
{
router->routerProfiling().MarkPathFail(p.get());
PathSet::HandlePathBuildTimeout(p);
LogWarn(Name(), " build interval is now ", buildIntervalLimit);
DoPathBuildBackoff();
}
void

@ -27,6 +27,9 @@ namespace llarp
UrgentBuild(llarp_time_t now) const;
private:
void
DoPathBuildBackoff();
bool
DoUrgentBuildAlignedTo(const RouterID remote,
std::vector< RouterContact >& hops);
@ -115,6 +118,9 @@ namespace llarp
virtual void
HandlePathBuildTimeout(Path_ptr p) override;
virtual void
HandlePathBuildFailed(Path_ptr p) override;
};
using Builder_ptr = std::shared_ptr< Builder >;

@ -291,6 +291,14 @@ namespace llarp
m_BuildStats.timeouts++;
}
void
PathSet::HandlePathBuildFailed(Path_ptr p)
{
LogWarn(Name(), " path build ", p->HopsString(), " failed");
m_BuildStats.fails ++;
}
void
PathSet::PathBuildStarted(Path_ptr p)
{

@ -128,6 +128,9 @@ namespace llarp
virtual void
HandlePathBuildTimeout(Path_ptr path);
virtual void
HandlePathBuildFailed(Path_ptr path);
virtual void
PathBuildStarted(Path_ptr path);

Loading…
Cancel
Save