fix up leak

This commit is contained in:
Jeff Becker 2018-11-20 10:46:26 -05:00
parent 2e3adb48e3
commit ab5f477907
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

View File

@ -54,6 +54,7 @@ struct TryConnectJob
Success() Success()
{ {
llarp::LogInfo("established session with ", rc.pubkey); llarp::LogInfo("established session with ", rc.pubkey);
router->FlushOutboundFor(rc.pubkey, link);
} }
void void
@ -328,14 +329,11 @@ llarp_router::SaveRC()
void void
llarp_router::Close() llarp_router::Close()
{ {
llarp::LogInfo("Closing ", inboundLinks.size(), " server bindings");
for(const auto &link : inboundLinks) for(const auto &link : inboundLinks)
{ {
link->Stop(); link->Stop();
} }
inboundLinks.clear(); inboundLinks.clear();
llarp::LogInfo("Closing LokiNetwork client");
if(outboundLink) if(outboundLink)
{ {
outboundLink->Stop(); outboundLink->Stop();
@ -353,6 +351,7 @@ llarp_router::on_verify_client_rc(llarp_async_verify_rc *job)
llarp::PubKey pk(job->rc.pubkey); llarp::PubKey pk(job->rc.pubkey);
router->FlushOutboundFor(pk, router->GetLinkWithSessionByPubkey(pk)); router->FlushOutboundFor(pk, router->GetLinkWithSessionByPubkey(pk));
delete ctx; delete ctx;
delete job;
} }
void void
@ -370,6 +369,8 @@ llarp_router::on_verify_server_rc(llarp_async_verify_rc *job)
// was an outbound attempt // was an outbound attempt
ctx->establish_job->Failed(); ctx->establish_job->Failed();
} }
delete ctx;
delete job;
router->DiscardOutboundFor(pk); router->DiscardOutboundFor(pk);
return; return;
} }
@ -397,7 +398,10 @@ llarp_router::on_verify_server_rc(llarp_async_verify_rc *job)
{ {
ctx->establish_job->Success(); ctx->establish_job->Success();
} }
else
router->FlushOutboundFor(pk, router->GetLinkWithSessionByPubkey(pk)); router->FlushOutboundFor(pk, router->GetLinkWithSessionByPubkey(pk));
delete ctx;
delete job;
} }
void void
@ -659,13 +663,27 @@ llarp_router::async_verify_RC(const llarp::RouterContact &rc)
// job->crypto = &crypto; // we already have this // job->crypto = &crypto; // we already have this
job->cryptoworker = tp; job->cryptoworker = tp;
job->diskworker = disk; job->diskworker = disk;
if(rpcCaller && rc.IsPublicRouter())
{
rpcCaller->VerifyRouter(rc.pubkey, [job, ctx](llarp::PubKey, bool valid) {
if(valid)
llarp_nodedb_async_verify(job);
else
{
delete job;
delete ctx;
}
});
}
else
{
if(rc.IsPublicRouter()) if(rc.IsPublicRouter())
job->hook = &llarp_router::on_verify_server_rc; job->hook = &llarp_router::on_verify_server_rc;
else else
job->hook = &llarp_router::on_verify_client_rc; job->hook = &llarp_router::on_verify_client_rc;
llarp_nodedb_async_verify(job); llarp_nodedb_async_verify(job);
} }
}
void void
llarp_router::Run() llarp_router::Run()