Fix a deadlock and some more work on RethinkDB (for central) integration.

This commit is contained in:
Adam Ierymenko 2017-11-08 11:06:14 -08:00
parent 53e7e950f1
commit 4166d8ca35
7 changed files with 106 additions and 83 deletions

View file

@ -34,14 +34,16 @@ public:
RethinkDB(EmbeddedNetworkController *const nc,const Address &myAddress,const char *path);
virtual ~RethinkDB();
virtual void waitForReady();
virtual bool waitForReady();
virtual void save(const nlohmann::json &record);
virtual void save(nlohmann::json *orig,nlohmann::json &record);
virtual void eraseNetwork(const uint64_t networkId);
virtual void eraseMember(const uint64_t networkId,const uint64_t memberId);
virtual void nodeIsOnline(const uint64_t memberId);
protected:
std::string _host;
std::string _db;
@ -56,6 +58,10 @@ protected:
BlockingQueue< nlohmann::json * > _commitQueue;
std::thread _commitThread[ZT_CONTROLLER_RETHINKDB_COMMIT_THREADS];
std::unordered_map< uint64_t,int64_t > _lastOnline;
mutable std::mutex _lastOnline_l;
std::thread _onlineNotificationThread;
std::thread _heartbeatThread;
mutable std::mutex _readyLock; // locked until ready