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
// 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
{
@ -125,36 +128,31 @@ namespace llarp
static void
PathBuilderKeysGenerated(std::shared_ptr<AsyncPathKeyExchangeContext> ctx)
{
if (!ctx->pathset->IsStopped())
{
ctx->router->NotifyRouterEvent<tooling::PathAttemptEvent>(ctx->router->pubkey(), ctx->path);
if (ctx->pathset->IsStopped())
return;
const RouterID remote = ctx->path->Upstream();
auto sentHandler = [ctx](auto status) {
if (status == SendStatus::Success)
{
ctx->router->pathContext().AddOwnPath(ctx->pathset, ctx->path);
ctx->pathset->PathBuildStarted(std::move(ctx->path));
}
else
{
LogError(ctx->pathset->Name(), " failed to send LRCM to ", ctx->path->Upstream());
ctx->path->EnterState(path::ePathFailed, ctx->router->Now());
}
ctx->path = nullptr;
ctx->pathset = nullptr;
};
if (ctx->router->SendToOrQueue(remote, ctx->LRCM, sentHandler))
{
// persist session with router until this path is done
if (ctx->path)
ctx->router->PersistSessionUntil(remote, ctx->path->ExpireTime());
}
else
ctx->router->NotifyRouterEvent<tooling::PathAttemptEvent>(ctx->router->pubkey(), ctx->path);
ctx->router->pathContext().AddOwnPath(ctx->pathset, ctx->path);
ctx->pathset->PathBuildStarted(ctx->path);
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 queue LRCM to ", remote);
sentHandler(SendStatus::NoLink);
path->EnterState(path::ePathFailed, router->Now());
}
};
if (ctx->router->SendToOrQueue(remote, ctx->LRCM, sentHandler))
{
// persist session with router until this path is done
if (ctx->path)
ctx->router->PersistSessionUntil(remote, ctx->path->ExpireTime());
}
else
{
LogError(ctx->pathset->Name(), " failed to queue LRCM to ", remote);
sentHandler(SendStatus::NoLink);
}
}

Loading…
Cancel
Save