mirror of
https://github.com/oxen-io/lokinet
synced 2023-12-14 06:53:00 +01:00
try fixing std::shared_ptr leak with paths
This commit is contained in:
parent
d514f30eaa
commit
397d8b01fc
1 changed files with 26 additions and 28 deletions
|
@ -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))
|
||||
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)
|
||||
{
|
||||
// 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);
|
||||
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…
Reference in a new issue