mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-02 07:20:51 +00:00
Error recovery for network & member stream watchers
This commit is contained in:
parent
0f17508cac
commit
8b8399efbc
@ -735,6 +735,7 @@ void PostgreSQL::_membersWatcher_Redis() {
|
|||||||
std::string key = "member-stream:{" + std::string(_myAddress.toString(buf)) + "}";
|
std::string key = "member-stream:{" + std::string(_myAddress.toString(buf)) + "}";
|
||||||
|
|
||||||
while (_run == 1) {
|
while (_run == 1) {
|
||||||
|
try {
|
||||||
json tmp;
|
json tmp;
|
||||||
std::unordered_map<std::string, ItemStream> result;
|
std::unordered_map<std::string, ItemStream> result;
|
||||||
if (_rc->clusterMode) {
|
if (_rc->clusterMode) {
|
||||||
@ -744,20 +745,20 @@ void PostgreSQL::_membersWatcher_Redis() {
|
|||||||
}
|
}
|
||||||
if (!result.empty()) {
|
if (!result.empty()) {
|
||||||
for (auto element : result) {
|
for (auto element : result) {
|
||||||
#ifdef ZT_TRACE
|
#ifdef ZT_TRACE
|
||||||
fprintf(stdout, "Received notification from: %s\n", element.first.c_str());
|
fprintf(stdout, "Received notification from: %s\n", element.first.c_str());
|
||||||
#endif
|
#endif
|
||||||
for (auto rec : element.second) {
|
for (auto rec : element.second) {
|
||||||
std::string id = rec.first;
|
std::string id = rec.first;
|
||||||
auto attrs = rec.second;
|
auto attrs = rec.second;
|
||||||
#ifdef ZT_TRACE
|
#ifdef ZT_TRACE
|
||||||
fprintf(stdout, "Record ID: %s\n", id.c_str());
|
fprintf(stdout, "Record ID: %s\n", id.c_str());
|
||||||
fprintf(stdout, "attrs len: %lu\n", attrs.size());
|
fprintf(stdout, "attrs len: %lu\n", attrs.size());
|
||||||
#endif
|
#endif
|
||||||
for (auto a : attrs) {
|
for (auto a : attrs) {
|
||||||
#ifdef ZT_TRACE
|
#ifdef ZT_TRACE
|
||||||
fprintf(stdout, "key: %s\nvalue: %s\n", a.first.c_str(), a.second.c_str());
|
fprintf(stdout, "key: %s\nvalue: %s\n", a.first.c_str(), a.second.c_str());
|
||||||
#endif
|
#endif
|
||||||
try {
|
try {
|
||||||
tmp = json::parse(a.second);
|
tmp = json::parse(a.second);
|
||||||
json &ov = tmp["old_val"];
|
json &ov = tmp["old_val"];
|
||||||
@ -780,6 +781,9 @@ void PostgreSQL::_membersWatcher_Redis() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (sw::redis::Error &e) {
|
||||||
|
fprintf(stderr, "Error in Redis members watcher: %s\n", e.what());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fprintf(stderr, "membersWatcher ended\n");
|
fprintf(stderr, "membersWatcher ended\n");
|
||||||
}
|
}
|
||||||
@ -856,6 +860,7 @@ void PostgreSQL::_networksWatcher_Redis() {
|
|||||||
std::string key = "network-stream:{" + std::string(_myAddress.toString(buf)) + "}";
|
std::string key = "network-stream:{" + std::string(_myAddress.toString(buf)) + "}";
|
||||||
|
|
||||||
while (_run == 1) {
|
while (_run == 1) {
|
||||||
|
try {
|
||||||
json tmp;
|
json tmp;
|
||||||
std::unordered_map<std::string, ItemStream> result;
|
std::unordered_map<std::string, ItemStream> result;
|
||||||
if (_rc->clusterMode) {
|
if (_rc->clusterMode) {
|
||||||
@ -902,6 +907,9 @@ void PostgreSQL::_networksWatcher_Redis() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (sw::redis::Error &e) {
|
||||||
|
fprintf(stderr, "Error in Redis networks watcher: %s\n", e.what());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fprintf(stderr, "networksWatcher ended\n");
|
fprintf(stderr, "networksWatcher ended\n");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user