mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2024-12-24 07:06:39 +00:00
Deadlock fix.
This commit is contained in:
parent
7c184cf991
commit
e8ab6adf89
@ -60,6 +60,15 @@ JSONDB::JSONDB(const std::string &basePath) :
|
||||
|
||||
for(std::unordered_map<uint64_t,_NW>::iterator n(_networks.begin());n!=_networks.end();++n)
|
||||
_recomputeSummaryInfo(n->first);
|
||||
for(;;) {
|
||||
_summaryThread_m.lock();
|
||||
if (_summaryThreadToDo.empty()) {
|
||||
_summaryThread_m.unlock();
|
||||
break;
|
||||
}
|
||||
_summaryThread_m.unlock();
|
||||
Thread::sleep(50);
|
||||
}
|
||||
}
|
||||
|
||||
JSONDB::~JSONDB()
|
||||
@ -107,7 +116,7 @@ void JSONDB::saveNetwork(const uint64_t networkId,const nlohmann::json &networkC
|
||||
Mutex::Lock _l(_networks_m);
|
||||
_networks[networkId].config = networkConfig;
|
||||
}
|
||||
//_recomputeSummaryInfo(networkId);
|
||||
_recomputeSummaryInfo(networkId);
|
||||
}
|
||||
|
||||
void JSONDB::saveNetworkMember(const uint64_t networkId,const uint64_t nodeId,const nlohmann::json &memberConfig)
|
||||
|
@ -82,19 +82,12 @@ public:
|
||||
|
||||
inline bool getNetworkSummaryInfo(const uint64_t networkId,NetworkSummaryInfo &ns) const
|
||||
{
|
||||
for(;;) {
|
||||
{
|
||||
Mutex::Lock _l(_networks_m);
|
||||
std::unordered_map<uint64_t,_NW>::const_iterator i(_networks.find(networkId));
|
||||
if (i == _networks.end())
|
||||
return false;
|
||||
if (i->second.summaryInfoLastComputed) {
|
||||
ns = i->second.summaryInfo;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Thread::sleep(100); // wait for this to be done the first time, which happens when we start
|
||||
}
|
||||
Mutex::Lock _l(_networks_m);
|
||||
std::unordered_map<uint64_t,_NW>::const_iterator i(_networks.find(networkId));
|
||||
if (i == _networks.end())
|
||||
return false;
|
||||
ns = i->second.summaryInfo;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user