Merge pull request #1621 from majestrate/path-ptr-leak-2021-05-02

try fixing std::shared_ptr leak with paths
pull/1627/head
Jeff 3 years ago committed by GitHub
commit d53945b011
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -96,7 +96,10 @@ namespace llarp
{ {
// farthest hop // farthest hop
// TODO: encrypt junk frames because our public keys are not eligator // TODO: encrypt junk frames because our public keys are not eligator
loop->call([self = shared_from_this()] { self->result(self); }); loop->call([self = shared_from_this()] {
self->result(self);
self->result = nullptr;
});
} }
else else
{ {
@ -125,24 +128,20 @@ namespace llarp
static void static void
PathBuilderKeysGenerated(std::shared_ptr<AsyncPathKeyExchangeContext> ctx) PathBuilderKeysGenerated(std::shared_ptr<AsyncPathKeyExchangeContext> ctx)
{ {
if (!ctx->pathset->IsStopped()) if (ctx->pathset->IsStopped())
{ return;
ctx->router->NotifyRouterEvent<tooling::PathAttemptEvent>(ctx->router->pubkey(), ctx->path); ctx->router->NotifyRouterEvent<tooling::PathAttemptEvent>(ctx->router->pubkey(), ctx->path);
const RouterID remote = ctx->path->Upstream();
auto sentHandler = [ctx](auto status) {
if (status == SendStatus::Success)
{
ctx->router->pathContext().AddOwnPath(ctx->pathset, ctx->path); ctx->router->pathContext().AddOwnPath(ctx->pathset, ctx->path);
ctx->pathset->PathBuildStarted(std::move(ctx->path)); ctx->pathset->PathBuildStarted(ctx->path);
}
else const RouterID remote = ctx->path->Upstream();
auto sentHandler = [router = ctx->router, path = ctx->path](auto status) {
if (status != SendStatus::Success)
{ {
LogError(ctx->pathset->Name(), " failed to send LRCM to ", ctx->path->Upstream()); path->EnterState(path::ePathFailed, router->Now());
ctx->path->EnterState(path::ePathFailed, ctx->router->Now());
} }
ctx->path = nullptr;
ctx->pathset = nullptr;
}; };
if (ctx->router->SendToOrQueue(remote, ctx->LRCM, sentHandler)) if (ctx->router->SendToOrQueue(remote, ctx->LRCM, sentHandler))
{ {
@ -156,7 +155,6 @@ namespace llarp
sentHandler(SendStatus::NoLink); sentHandler(SendStatus::NoLink);
} }
} }
}
namespace path namespace path
{ {

Loading…
Cancel
Save