Merge branch 'dev' into rusty-tcp-relay

This commit is contained in:
Adam Ierymenko 2024-06-24 18:53:25 -04:00
commit f4edb092b7
2 changed files with 21 additions and 3 deletions

View File

@ -382,6 +382,24 @@ void DB::_networkChanged(nlohmann::json &old,nlohmann::json &networkConfig,bool
const std::string ids = old["id"]; const std::string ids = old["id"];
const uint64_t networkId = Utils::hexStrToU64(ids.c_str()); const uint64_t networkId = Utils::hexStrToU64(ids.c_str());
if (networkId) { if (networkId) {
try {
// deauth all members on the network
nlohmann::json network;
std::vector<nlohmann::json> members;
this->get(networkId, network, members);
for(auto i=members.begin();i!=members.end();++i) {
const std::string nodeID = (*i)["id"];
const uint64_t memberId = Utils::hexStrToU64(nodeID.c_str());
std::unique_lock<std::shared_mutex> ll(_changeListeners_l);
for(auto j=_changeListeners.begin();j!=_changeListeners.end();++j) {
(*j)->onNetworkMemberDeauthorize(this,networkId,memberId);
}
}
} catch (std::exception &e) {
std::cerr << "Error deauthorizing members on network delete: " << e.what() << std::endl;
}
// delete the network
std::unique_lock<std::shared_mutex> l(_networks_l); std::unique_lock<std::shared_mutex> l(_networks_l);
_networks.erase(networkId); _networks.erase(networkId);
} }

View File

@ -1180,7 +1180,7 @@ void PostgreSQL::_membersWatcher_Redis() {
_memberChanged(oldConfig,newConfig,(this->_ready >= 2)); _memberChanged(oldConfig,newConfig,(this->_ready >= 2));
} }
} catch (...) { } catch (...) {
fprintf(stderr, "json parse error in networkWatcher_Redis\n"); fprintf(stderr, "json parse error in _membersWatcher_Redis: %s\n", a.second.c_str());
} }
} }
if (_rc->clusterMode) { if (_rc->clusterMode) {
@ -1269,8 +1269,8 @@ void PostgreSQL::_networksWatcher_Redis() {
if (oldConfig.is_object()||newConfig.is_object()) { if (oldConfig.is_object()||newConfig.is_object()) {
_networkChanged(oldConfig,newConfig,(this->_ready >= 2)); _networkChanged(oldConfig,newConfig,(this->_ready >= 2));
} }
} catch (...) { } catch (std::exception &e) {
fprintf(stderr, "json parse error in networkWatcher_Redis\n"); fprintf(stderr, "json parse error in networkWatcher_Redis: what: %s json: %s\n", e.what(), a.second.c_str());
} }
} }
if (_rc->clusterMode) { if (_rc->clusterMode) {