diff options
author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2019-08-08 15:29:13 -0500 |
---|---|---|
committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2019-08-08 15:29:13 -0500 |
commit | 28d0070ce2e791727c388646f22119e350ab6d78 (patch) | |
tree | 9cd411fad644e021b5ccb64e47c0ab8ac74358a6 /controller/FileDB.cpp | |
parent | ad2a7c2590467270486c15144330f2c3e87ec080 (diff) | |
download | infinitytier-28d0070ce2e791727c388646f22119e350ab6d78.tar.gz infinitytier-28d0070ce2e791727c388646f22119e350ab6d78.zip |
Fix race in multiple DB mirroring configurations.
Diffstat (limited to 'controller/FileDB.cpp')
-rw-r--r-- | controller/FileDB.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/controller/FileDB.cpp b/controller/FileDB.cpp index 1dc2498a..cf5847d6 100644 --- a/controller/FileDB.cpp +++ b/controller/FileDB.cpp @@ -98,7 +98,7 @@ bool FileDB::save(nlohmann::json &record,bool notifyListeners) if (nwid) { nlohmann::json old; get(nwid,old); - if ((!old.is_object())||(old != record)) { + if ((!old.is_object())||(!_compareRecords(old,record))) { record["revision"] = OSUtils::jsonInt(record["revision"],0ULL) + 1ULL; OSUtils::ztsnprintf(p1,sizeof(p1),"%s" ZT_PATH_SEPARATOR_S "%.16llx.json",_networksPath.c_str(),nwid); if (!OSUtils::writeFile(p1,OSUtils::jsonDump(record,-1))) @@ -115,7 +115,7 @@ bool FileDB::save(nlohmann::json &record,bool notifyListeners) if ((id)&&(nwid)) { nlohmann::json network,old; get(nwid,network,id,old); - if ((!old.is_object())||(old != record)) { + if ((!old.is_object())||(!_compareRecords(old,record))) { record["revision"] = OSUtils::jsonInt(record["revision"],0ULL) + 1ULL; OSUtils::ztsnprintf(pb,sizeof(pb),"%s" ZT_PATH_SEPARATOR_S "%.16llx" ZT_PATH_SEPARATOR_S "member",_networksPath.c_str(),(unsigned long long)nwid); OSUtils::ztsnprintf(p1,sizeof(p1),"%s" ZT_PATH_SEPARATOR_S "%.10llx.json",pb,(unsigned long long)id); |