diff --git a/llarp/messages/relay_commit.cpp b/llarp/messages/relay_commit.cpp index 22fd0e33a..cdcc9f57b 100644 --- a/llarp/messages/relay_commit.cpp +++ b/llarp/messages/relay_commit.cpp @@ -456,6 +456,8 @@ namespace llarp self->decrypter = nullptr; }); } + // trigger idempotent pump to ensure that the build messages propagate + self->context->Router()->TriggerPump(); } }; diff --git a/llarp/messages/relay_status.cpp b/llarp/messages/relay_status.cpp index 9ea58a55b..ceee052e9 100644 --- a/llarp/messages/relay_status.cpp +++ b/llarp/messages/relay_status.cpp @@ -221,24 +221,35 @@ namespace llarp std::shared_ptr 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 msg) + AbstractRouter* router, + const RouterID nextHop, + std::shared_ptr msg, + std::shared_ptr 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 diff --git a/llarp/messages/relay_status.hpp b/llarp/messages/relay_status.hpp index b331cd622..265ce6a08 100644 --- a/llarp/messages/relay_status.hpp +++ b/llarp/messages/relay_status.hpp @@ -105,7 +105,10 @@ namespace llarp static void SendMessage( - AbstractRouter* router, const RouterID nextHop, std::shared_ptr msg); + AbstractRouter* router, + const RouterID nextHop, + std::shared_ptr msg, + std::shared_ptr hop); const char* Name() const override