fix minor oversight/inefficiency with already established connections

This commit is contained in:
Thomas Winget 2021-06-29 18:44:42 -04:00
parent bff81c62e2
commit 8515fe09d4
1 changed files with 16 additions and 0 deletions

View File

@ -80,6 +80,14 @@ namespace llarp
CreatePendingSession(router);
// short-circuit to success callback if we already have an outbound session
// to the remote
if (_linkManager->HasOutboundSessionTo(router))
{
FinalizeRequest(router, SessionResult::Establish);
return;
}
LogDebug("Creating session establish attempt to ", router, " .");
auto fn = util::memFn(&OutboundSessionMaker::OnRouterContactResult, this);
@ -104,6 +112,14 @@ namespace llarp
CreatePendingSession(rc.pubkey);
}
// short-circuit to success callback if we already have an outbound session
// to the remote
if (_linkManager->HasOutboundSessionTo(router))
{
FinalizeRequest(router, SessionResult::Establish);
return;
}
GotRouterContact(rc.pubkey, rc);
}