Merge pull request #1891 from majestrate/idempotent-flush-path-builds-2022-04-12

idempotent flush queues on path builds
This commit is contained in:
majestrate 2022-04-18 15:54:09 -04:00 committed by GitHub
commit d972b04fe0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 12 deletions

View File

@ -456,6 +456,8 @@ namespace llarp
self->decrypter = nullptr;
});
}
// trigger idempotent pump to ensure that the build messages propagate
self->context->Router()->TriggerPump();
}
};

View File

@ -221,24 +221,35 @@ namespace llarp
std::shared_ptr<path::TransitHop> hop)
{
router->loop()->call([router, nextHop, msg = std::move(msg), hop = std::move(hop)] {
SendMessage(router, nextHop, msg);
// destroy hop as needed
if ((msg->status & LR_StatusRecord::SUCCESS) != LR_StatusRecord::SUCCESS)
{
hop->QueueDestroySelf(router);
}
SendMessage(router, nextHop, msg, hop);
});
}
void
LR_StatusMessage::SendMessage(
AbstractRouter* router, const RouterID nextHop, std::shared_ptr<LR_StatusMessage> msg)
AbstractRouter* router,
const RouterID nextHop,
std::shared_ptr<LR_StatusMessage> msg,
std::shared_ptr<path::TransitHop> hop)
{
llarp::LogDebug("Attempting to send LR_Status message to (", nextHop, ")");
if (not router->SendToOrQueue(nextHop, *msg))
{
llarp::LogError("Sending LR_Status message, SendToOrQueue to ", nextHop, " failed");
}
auto resultCallback = [hop, router, msg, nextHop](auto status) {
if ((msg->status & LR_StatusRecord::SUCCESS) != LR_StatusRecord::SUCCESS
or status != SendStatus::Success)
{
llarp::LogError("Failed to propagate LR_Status message to ", nextHop);
hop->QueueDestroySelf(router);
}
};
// send the status message to previous hop
// if it fails we are hitting a failure case we can't cope with so ... drop.
if (not router->SendToOrQueue(nextHop, *msg, resultCallback))
resultCallback(SendStatus::Congestion);
// trigger idempotent pump to make sure stuff gets sent
router->TriggerPump();
}
bool

View File

@ -105,7 +105,10 @@ namespace llarp
static void
SendMessage(
AbstractRouter* router, const RouterID nextHop, std::shared_ptr<LR_StatusMessage> msg);
AbstractRouter* router,
const RouterID nextHop,
std::shared_ptr<LR_StatusMessage> msg,
std::shared_ptr<path::TransitHop> hop);
const char*
Name() const override