From 5f55e53331dd8a96125f459d554e9f404f8d4daa Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Fri, 24 May 2019 11:28:39 -0400 Subject: [PATCH] prefer inbound links over outbound links --- llarp/router/router.cpp | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/llarp/router/router.cpp b/llarp/router/router.cpp index ad5f506b6..b0d16dd14 100644 --- a/llarp/router/router.cpp +++ b/llarp/router/router.cpp @@ -1350,12 +1350,12 @@ namespace llarp if(selected->SendTo(remote, buf)) return; } - for(const auto &link : outboundLinks) + for(const auto &link : inboundLinks) { if(link->SendTo(remote, buf)) return; } - for(const auto &link : inboundLinks) + for(const auto &link : outboundLinks) { if(link->SendTo(remote, buf)) return; @@ -1407,22 +1407,37 @@ namespace llarp pendingEstablishJobs.erase(remote); return; } + // if for some reason we don't provide a link layer pick one that has it if(!chosen) { - DiscardOutboundFor(remote); - pendingEstablishJobs.erase(remote); - return; + for(const auto & link : inboundLinks) + { + if(link->HasSessionTo(remote)) + { + chosen = link.get(); + break; + } + } + for(const auto & link : outboundLinks) + { + if(link->HasSessionTo(remote)) + { + chosen = link.get(); + break; + } + } } while(itr->second.size()) { llarp_buffer_t buf(itr->second.front()); if(!chosen->SendTo(remote, buf)) - LogWarn("failed to send outbound message to ", remote, " via ", + LogWarn("failed to send queued outbound message to ", remote, " via ", chosen->Name()); itr->second.pop(); } pendingEstablishJobs.erase(remote); + outboundMessageQueue.erase(itr); } void