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

prevent deadlock

This commit is contained in:
Jeff Becker 2019-02-08 08:04:12 -05:00
parent faf8149502
commit 2dfb53ef13
No known key found for this signature in database
GPG key ID: F357B3B42F6F9B05
3 changed files with 15 additions and 4 deletions

View file

@ -35,9 +35,12 @@ llarp_nodedb::Clear()
}
bool
llarp_nodedb::Get(const llarp::RouterID &pk, llarp::RouterContact &result)
llarp_nodedb::Get(const llarp::RouterID &pk, llarp::RouterContact &result,
bool lock)
{
llarp::util::Lock lock(access);
std::unique_ptr< llarp::util::Lock > l;
if(lock)
l.reset(new llarp::util::Lock(access));
auto itr = entries.find(pk);
if(itr == entries.end())
return false;

View file

@ -55,7 +55,8 @@ struct llarp_nodedb
Clear();
bool
Get(const llarp::RouterID &pk, llarp::RouterContact &result);
Get(const llarp::RouterID &pk, llarp::RouterContact &result,
bool lock = true);
bool
Has(const llarp::RouterID &pk);

View file

@ -82,11 +82,18 @@ namespace llarp
++itr;
}
}
auto ep = getFirstEndpoint();
if(!ep)
return;
std::vector< RouterID > expired;
m_Router->nodedb()->visit([&](const RouterContact &rc) -> bool {
if(rc.IsExpired(now))
getFirstEndpoint()->LookupRouterAnon(rc.pubkey);
expired.emplace_back(rc.pubkey);
return true;
});
for(const auto &k : expired)
ep->LookupRouterAnon(k);
}
bool