Preparing for test.

This commit is contained in:
Adam Ierymenko 2017-11-03 12:32:56 -07:00
parent f5014d7d71
commit d97adc8789
4 changed files with 20 additions and 4 deletions

View file

@ -1064,7 +1064,6 @@ unsigned int EmbeddedNetworkController::handleControlPlaneHttpDELETE(
void EmbeddedNetworkController::handleRemoteTrace(const ZT_RemoteTrace &rt) void EmbeddedNetworkController::handleRemoteTrace(const ZT_RemoteTrace &rt)
{ {
/*
static volatile unsigned long idCounter = 0; static volatile unsigned long idCounter = 0;
char id[128],tmp[128]; char id[128],tmp[128];
std::string k,v; std::string k,v;
@ -1107,10 +1106,10 @@ void EmbeddedNetworkController::handleRemoteTrace(const ZT_RemoteTrace &rt)
d["objtype"] = "trace"; d["objtype"] = "trace";
d["ts"] = now; d["ts"] = now;
d["nodeId"] = Utils::hex10(rt.origin,tmp); d["nodeId"] = Utils::hex10(rt.origin,tmp);
_db.save(d);
} catch ( ... ) { } catch ( ... ) {
// drop invalid trace messages if an error occurs // drop invalid trace messages if an error occurs
} }
*/
} }
void EmbeddedNetworkController::onNetworkUpdate(const uint64_t networkId) void EmbeddedNetworkController::onNetworkUpdate(const uint64_t networkId)

View file

@ -19,8 +19,6 @@
#ifndef ZT_SQLITENETWORKCONTROLLER_HPP #ifndef ZT_SQLITENETWORKCONTROLLER_HPP
#define ZT_SQLITENETWORKCONTROLLER_HPP #define ZT_SQLITENETWORKCONTROLLER_HPP
#define ZT_CONTROLLER_USE_RETHINKDB
#include <stdint.h> #include <stdint.h>
#include <string> #include <string>

View file

@ -164,6 +164,9 @@ RethinkDB::RethinkDB(EmbeddedNetworkController *const nc,const Address &myAddres
const std::string tmp = (*config)["id"]; const std::string tmp = (*config)["id"];
deleteId.append(tmp); deleteId.append(tmp);
table = "Member"; table = "Member";
} else if (objtype == "trace") {
record = *config;
table = "RemoteTrace";
} else { } else {
continue; continue;
} }
@ -452,6 +455,21 @@ void RethinkDB::_memberChanged(nlohmann::json &old,nlohmann::json &member)
_controller->onNetworkMemberUpdate(networkId,memberId); _controller->onNetworkMemberUpdate(networkId,memberId);
} }
} else if (memberId) {
if (nw) {
std::lock_guard<std::mutex> l(nw->lock);
nw->members.erase(memberId);
}
if (networkId) {
std::lock_guard<std::mutex> l(_networks_l);
auto er = _networkByMember.equal_range(memberId);
for(auto i=er.first;i!=er.second;++i) {
if (i->second == networkId) {
_networkByMember.erase(i);
break;
}
}
}
} }
if ((wasAuth)&&(!isAuth)&&(networkId)&&(memberId)) if ((wasAuth)&&(!isAuth)&&(networkId)&&(memberId))

View file

@ -132,6 +132,7 @@ private:
std::thread _membersDbWatcher; std::thread _membersDbWatcher;
std::unordered_map< uint64_t,std::shared_ptr<_Network> > _networks; std::unordered_map< uint64_t,std::shared_ptr<_Network> > _networks;
std::unordered_multimap< uint64_t,uint64_t > _networkByMember;
mutable std::mutex _networks_l; mutable std::mutex _networks_l;
BlockingQueue< std::unique_ptr<nlohmann::json> > _commitQueue; BlockingQueue< std::unique_ptr<nlohmann::json> > _commitQueue;