mirror of
https://github.com/oxen-io/lokinet
synced 2023-12-14 06:53:00 +01:00
prevent deadlock
This commit is contained in:
parent
faf8149502
commit
2dfb53ef13
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue