1
1
Fork 0
mirror of https://github.com/oxen-io/lokinet synced 2023-12-14 06:53:00 +01:00

don't send path build if we shut down

This commit is contained in:
Jeff Becker 2018-12-24 11:21:15 -05:00
parent d71b59bfa6
commit 414c7d659c
No known key found for this signature in database
GPG key ID: F357B3B42F6F9B05
2 changed files with 19 additions and 12 deletions

View file

@ -138,19 +138,20 @@ namespace llarp
static void
PathBuilderKeysGenerated(AsyncPathKeyExchangeContext< path::Builder >* ctx)
{
RouterID remote = ctx->path->Upstream();
const ILinkMessage* msg = &ctx->LRCM;
if(!ctx->router->SendToOrQueue(remote, msg))
if(ctx->pathset->CanBuildPaths())
{
llarp::LogError("failed to send LRCM to ", remote);
ctx->pathset->keygens--;
return;
RouterID remote = ctx->path->Upstream();
const ILinkMessage* msg = &ctx->LRCM;
if(ctx->router->SendToOrQueue(remote, msg))
{
// persist session with router until this path is done
ctx->router->PersistSessionUntil(remote, ctx->path->ExpireTime());
// add own path
ctx->router->paths.AddOwnPath(ctx->pathset, ctx->path);
}
else
llarp::LogError("failed to send LRCM to ", remote);
}
// persist session with router until this path is done
ctx->router->PersistSessionUntil(remote, ctx->path->ExpireTime());
// add own path
ctx->router->paths.AddOwnPath(ctx->pathset, ctx->path);
// decrement keygen counter
ctx->pathset->keygens--;
}
@ -204,7 +205,7 @@ namespace llarp
bool
Builder::ShouldRemove() const
{
if(_run)
if(CanBuildPaths())
return false;
return keygens.load() > 0;
}

View file

@ -18,6 +18,12 @@ namespace llarp
std::atomic< bool > _run;
public:
bool
CanBuildPaths() const
{
return _run.load();
}
llarp::Router* router;
struct llarp_dht_context* dht;
llarp::SecretKey enckey;