mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-06 20:43:44 +02:00
Fix deadlock bug.
This commit is contained in:
parent
8898cb342b
commit
6174c0c103
2 changed files with 16 additions and 12 deletions
|
@ -51,7 +51,7 @@ bool DBMirrorSet::get(const uint64_t networkId,nlohmann::json &network)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> l(_dbs_l);
|
std::lock_guard<std::mutex> l(_dbs_l);
|
||||||
for(auto d=_dbs.begin();d!=_dbs.end();++d) {
|
for(auto d=_dbs.begin();d!=_dbs.end();++d) {
|
||||||
if (get(networkId,network)) {
|
if ((*d)->get(networkId,network)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ bool DBMirrorSet::get(const uint64_t networkId,nlohmann::json &network,const uin
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> l(_dbs_l);
|
std::lock_guard<std::mutex> l(_dbs_l);
|
||||||
for(auto d=_dbs.begin();d!=_dbs.end();++d) {
|
for(auto d=_dbs.begin();d!=_dbs.end();++d) {
|
||||||
if (get(networkId,network,memberId,member))
|
if ((*d)->get(networkId,network,memberId,member))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -72,7 +72,7 @@ bool DBMirrorSet::get(const uint64_t networkId,nlohmann::json &network,const uin
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> l(_dbs_l);
|
std::lock_guard<std::mutex> l(_dbs_l);
|
||||||
for(auto d=_dbs.begin();d!=_dbs.end();++d) {
|
for(auto d=_dbs.begin();d!=_dbs.end();++d) {
|
||||||
if (get(networkId,network,memberId,member,info))
|
if ((*d)->get(networkId,network,memberId,member,info))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -82,7 +82,7 @@ bool DBMirrorSet::get(const uint64_t networkId,nlohmann::json &network,std::vect
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> l(_dbs_l);
|
std::lock_guard<std::mutex> l(_dbs_l);
|
||||||
for(auto d=_dbs.begin();d!=_dbs.end();++d) {
|
for(auto d=_dbs.begin();d!=_dbs.end();++d) {
|
||||||
if (get(networkId,network,members))
|
if ((*d)->get(networkId,network,members))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -118,16 +118,20 @@ bool DBMirrorSet::isReady()
|
||||||
|
|
||||||
bool DBMirrorSet::save(nlohmann::json &record,bool notifyListeners)
|
bool DBMirrorSet::save(nlohmann::json &record,bool notifyListeners)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> l(_dbs_l);
|
std::vector< std::shared_ptr<DB> > dbs;
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> l(_dbs_l);
|
||||||
|
dbs = _dbs;
|
||||||
|
}
|
||||||
if (notifyListeners) {
|
if (notifyListeners) {
|
||||||
for(auto d=_dbs.begin();d!=_dbs.end();++d) {
|
for(auto d=dbs.begin();d!=dbs.end();++d) {
|
||||||
if ((*d)->save(record,notifyListeners))
|
if ((*d)->save(record,notifyListeners))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
bool modified = false;
|
bool modified = false;
|
||||||
for(auto d=_dbs.begin();d!=_dbs.end();++d) {
|
for(auto d=dbs.begin();d!=dbs.end();++d) {
|
||||||
modified |= (*d)->save(record,notifyListeners);
|
modified |= (*d)->save(record,notifyListeners);
|
||||||
}
|
}
|
||||||
return modified;
|
return modified;
|
||||||
|
|
|
@ -83,7 +83,7 @@ LFDB::LFDB(const Identity &myId,const char *path,const char *lfOwnerPrivate,cons
|
||||||
if (resp) {
|
if (resp) {
|
||||||
if (resp->status == 200) {
|
if (resp->status == 200) {
|
||||||
ns->second.dirty = false;
|
ns->second.dirty = false;
|
||||||
printf("SET network %.16llx %s\n",ns->first,resp->body.c_str());
|
//printf("SET network %.16llx %s\n",ns->first,resp->body.c_str());
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr,"ERROR: LFDB: %d from node (create/update network): %s" ZT_EOL_S,resp->status,resp->body.c_str());
|
fprintf(stderr,"ERROR: LFDB: %d from node (create/update network): %s" ZT_EOL_S,resp->status,resp->body.c_str());
|
||||||
}
|
}
|
||||||
|
@ -129,7 +129,7 @@ LFDB::LFDB(const Identity &myId,const char *path,const char *lfOwnerPrivate,cons
|
||||||
if (resp) {
|
if (resp) {
|
||||||
if (resp->status == 200) {
|
if (resp->status == 200) {
|
||||||
ms->second.lastOnlineDirty = false;
|
ms->second.lastOnlineDirty = false;
|
||||||
printf("SET member online %.16llx %.10llx %s\n",ns->first,ms->first,resp->body.c_str());
|
//printf("SET member online %.16llx %.10llx %s\n",ns->first,ms->first,resp->body.c_str());
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr,"ERROR: LFDB: %d from node (create/update member online status): %s" ZT_EOL_S,resp->status,resp->body.c_str());
|
fprintf(stderr,"ERROR: LFDB: %d from node (create/update member online status): %s" ZT_EOL_S,resp->status,resp->body.c_str());
|
||||||
}
|
}
|
||||||
|
@ -157,7 +157,7 @@ LFDB::LFDB(const Identity &myId,const char *path,const char *lfOwnerPrivate,cons
|
||||||
if (resp) {
|
if (resp) {
|
||||||
if (resp->status == 200) {
|
if (resp->status == 200) {
|
||||||
ms->second.dirty = false;
|
ms->second.dirty = false;
|
||||||
printf("SET member %.16llx %.10llx %s\n",ns->first,ms->first,resp->body.c_str());
|
//printf("SET member %.16llx %.10llx %s\n",ns->first,ms->first,resp->body.c_str());
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr,"ERROR: LFDB: %d from node (create/update member): %s" ZT_EOL_S,resp->status,resp->body.c_str());
|
fprintf(stderr,"ERROR: LFDB: %d from node (create/update member): %s" ZT_EOL_S,resp->status,resp->body.c_str());
|
||||||
}
|
}
|
||||||
|
@ -196,7 +196,7 @@ LFDB::LFDB(const Identity &myId,const char *path,const char *lfOwnerPrivate,cons
|
||||||
nlohmann::json &record = result["Record"];
|
nlohmann::json &record = result["Record"];
|
||||||
if (record.is_object()) {
|
if (record.is_object()) {
|
||||||
const std::string recordValue = result["Value"];
|
const std::string recordValue = result["Value"];
|
||||||
printf("GET network %s\n",recordValue.c_str());
|
//printf("GET network %s\n",recordValue.c_str());
|
||||||
nlohmann::json network(OSUtils::jsonParse(recordValue));
|
nlohmann::json network(OSUtils::jsonParse(recordValue));
|
||||||
if (network.is_object()) {
|
if (network.is_object()) {
|
||||||
const std::string idstr = network["id"];
|
const std::string idstr = network["id"];
|
||||||
|
@ -264,7 +264,7 @@ LFDB::LFDB(const Identity &myId,const char *path,const char *lfOwnerPrivate,cons
|
||||||
nlohmann::json &record = result["Record"];
|
nlohmann::json &record = result["Record"];
|
||||||
if (record.is_object()) {
|
if (record.is_object()) {
|
||||||
const std::string recordValue = result["Value"];
|
const std::string recordValue = result["Value"];
|
||||||
printf("GET member %s\n",recordValue.c_str());
|
//printf("GET member %s\n",recordValue.c_str());
|
||||||
nlohmann::json member(OSUtils::jsonParse(recordValue));
|
nlohmann::json member(OSUtils::jsonParse(recordValue));
|
||||||
if (member.is_object()) {
|
if (member.is_object()) {
|
||||||
const std::string nwidstr = member["nwid"];
|
const std::string nwidstr = member["nwid"];
|
||||||
|
|
Loading…
Add table
Reference in a new issue