idempotent flush queues on path builds

pull/1891/head
Jeff 2 years ago
parent f702aacc38
commit 3fbddac464

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

@ -221,24 +221,35 @@ namespace llarp
std::shared_ptr<path::TransitHop> hop) std::shared_ptr<path::TransitHop> hop)
{ {
router->loop()->call([router, nextHop, msg = std::move(msg), hop = std::move(hop)] { router->loop()->call([router, nextHop, msg = std::move(msg), hop = std::move(hop)] {
SendMessage(router, nextHop, msg); SendMessage(router, nextHop, msg, hop);
// destroy hop as needed
if ((msg->status & LR_StatusRecord::SUCCESS) != LR_StatusRecord::SUCCESS)
{
hop->QueueDestroySelf(router);
}
}); });
} }
void void
LR_StatusMessage::SendMessage( 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, ")"); llarp::LogDebug("Attempting to send LR_Status message to (", nextHop, ")");
if (not router->SendToOrQueue(nextHop, *msg))
{ auto resultCallback = [hop, router, msg, nextHop](auto status) {
llarp::LogError("Sending LR_Status message, SendToOrQueue to ", nextHop, " failed"); 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 bool

@ -105,7 +105,10 @@ namespace llarp
static void static void
SendMessage( 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* const char*
Name() const override Name() const override

Loading…
Cancel
Save