mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-05 12:03:44 +02:00
remove redundant writes when changes come from Central
network & member changes tagged with `"fromCentral": true` will not be rewritten to the db
This commit is contained in:
parent
610d4ff016
commit
f9396f979f
1 changed files with 377 additions and 369 deletions
|
@ -1078,6 +1078,10 @@ void PostgreSQL::commitThread()
|
|||
const std::string objtype = (*config)["objtype"];
|
||||
if (objtype == "member") {
|
||||
try {
|
||||
bool fromCentral = OSUtils::jsonBool((*config)["fromCentral"], false);
|
||||
if (!fromCentral) {
|
||||
// Central already writes all of this to the DB on a change.
|
||||
// No need for the controller to do it as well.
|
||||
std::string memberId = (*config)["id"];
|
||||
std::string networkId = (*config)["nwid"];
|
||||
std::string identity = (*config)["identity"];
|
||||
|
@ -1233,6 +1237,7 @@ void PostgreSQL::commitThread()
|
|||
config = nullptr;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
const uint64_t nwidInt = OSUtils::jsonIntHex((*config)["nwid"], 0ULL);
|
||||
const uint64_t memberidInt = OSUtils::jsonIntHex((*config)["id"], 0ULL);
|
||||
|
@ -1254,6 +1259,8 @@ void PostgreSQL::commitThread()
|
|||
}
|
||||
} else if (objtype == "network") {
|
||||
try {
|
||||
bool fromCentral = OSUtils::jsonBool((*config)["fromCentral"], false);
|
||||
if (!fromCentral) {
|
||||
std::string id = (*config)["id"];
|
||||
std::string controllerId = _myAddressStr.c_str();
|
||||
std::string name = (*config)["name"];
|
||||
|
@ -1519,6 +1526,7 @@ void PostgreSQL::commitThread()
|
|||
continue;
|
||||
}
|
||||
PQclear(res);
|
||||
}
|
||||
|
||||
const uint64_t nwidInt = OSUtils::jsonIntHex((*config)["nwid"], 0ULL);
|
||||
if (nwidInt) {
|
||||
|
@ -1639,7 +1647,7 @@ void PostgreSQL::commitThread()
|
|||
fprintf(stderr, "ERROR: Error getting objtype: %s\n", e.what());
|
||||
}
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
||||
}
|
||||
|
||||
PQfinish(conn);
|
||||
|
|
Loading…
Add table
Reference in a new issue