summaryrefslogtreecommitdiff
path: root/controller
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2017-11-03 16:59:36 -0400
committerAdam Ierymenko <adam.ierymenko@gmail.com>2017-11-03 16:59:36 -0400
commitb68bca35db1e8515ad981f8ebaef92637fa5b036 (patch)
tree1b1ddba3e3f2381c92420c0174abd919d4324058 /controller
parentd97adc8789c2a38d0106c83b0f02522f9cf0d7dd (diff)
downloadinfinitytier-b68bca35db1e8515ad981f8ebaef92637fa5b036.tar.gz
infinitytier-b68bca35db1e8515ad981f8ebaef92637fa5b036.zip
Linux build fixes, linux build rule for RethinkDB mode controller, also force disable shitty allocators in libstdc++.
Diffstat (limited to 'controller')
-rw-r--r--controller/EmbeddedNetworkController.cpp4
-rw-r--r--controller/EmbeddedNetworkController.hpp3
-rw-r--r--controller/RethinkDB.cpp42
-rw-r--r--controller/RethinkDB.hpp3
4 files changed, 22 insertions, 30 deletions
diff --git a/controller/EmbeddedNetworkController.cpp b/controller/EmbeddedNetworkController.cpp
index e8e0f5be..7cb931c6 100644
--- a/controller/EmbeddedNetworkController.cpp
+++ b/controller/EmbeddedNetworkController.cpp
@@ -496,7 +496,7 @@ void EmbeddedNetworkController::request(
qe->identity = identity;
qe->metaData = metaData;
qe->type = _RQEntry::RQENTRY_TYPE_REQUEST;
- _queue.post(std::unique_ptr<_RQEntry>(qe));
+ _queue.post(qe);
}
unsigned int EmbeddedNetworkController::handleControlPlaneHttpGET(
@@ -1720,7 +1720,7 @@ void EmbeddedNetworkController::_startThreads()
for(long t=0;t<hwc;++t) {
_threads.emplace_back([this]() {
for(;;) {
- std::unique_ptr<_RQEntry> qe;
+ _RQEntry *qe = (_RQEntry *)0;
if (_queue.get(qe))
break;
try {
diff --git a/controller/EmbeddedNetworkController.hpp b/controller/EmbeddedNetworkController.hpp
index f16ea121..7149df10 100644
--- a/controller/EmbeddedNetworkController.hpp
+++ b/controller/EmbeddedNetworkController.hpp
@@ -28,6 +28,7 @@
#include <list>
#include <thread>
#include <unordered_map>
+#include <atomic>
#include "../node/Constants.hpp"
#include "../node/NetworkController.hpp"
@@ -239,7 +240,7 @@ private:
std::string _signingIdAddressString;
NetworkController::Sender *_sender;
ControllerDB _db;
- BlockingQueue< std::unique_ptr<_RQEntry> > _queue;
+ BlockingQueue< _RQEntry * > _queue;
std::vector<std::thread> _threads;
std::mutex _threads_l;
std::unordered_map< _MemberStatusKey,_MemberStatus,_MemberStatusHash > _memberStatus;
diff --git a/controller/RethinkDB.cpp b/controller/RethinkDB.cpp
index ec6aae4e..6e656d23 100644
--- a/controller/RethinkDB.cpp
+++ b/controller/RethinkDB.cpp
@@ -132,7 +132,7 @@ RethinkDB::RethinkDB(EmbeddedNetworkController *const nc,const Address &myAddres
for(int t=0;t<ZT_CONTROLLER_RETHINKDB_COMMIT_THREADS;++t) {
_commitThread[t] = std::thread([this]() {
std::unique_ptr<R::Connection> rdb;
- std::unique_ptr<nlohmann::json> config;
+ nlohmann::json *config = (nlohmann::json *)0;
while ((this->_commitQueue.get(config))&&(_run == 1)) {
if (!config)
continue;
@@ -219,7 +219,7 @@ RethinkDB::~RethinkDB()
_networksDbWatcher.join();
}
-inline bool RethinkDB::get(const uint64_t networkId,nlohmann::json &network)
+bool RethinkDB::get(const uint64_t networkId,nlohmann::json &network)
{
waitForReady();
@@ -238,7 +238,7 @@ inline bool RethinkDB::get(const uint64_t networkId,nlohmann::json &network)
return true;
}
-inline bool RethinkDB::get(const uint64_t networkId,nlohmann::json &network,const uint64_t memberId,nlohmann::json &member)
+bool RethinkDB::get(const uint64_t networkId,nlohmann::json &network,const uint64_t memberId,nlohmann::json &member)
{
waitForReady();
@@ -261,7 +261,7 @@ inline bool RethinkDB::get(const uint64_t networkId,nlohmann::json &network,cons
return true;
}
-inline bool RethinkDB::get(const uint64_t networkId,nlohmann::json &network,const uint64_t memberId,nlohmann::json &member,NetworkSummaryInfo &info)
+bool RethinkDB::get(const uint64_t networkId,nlohmann::json &network,const uint64_t memberId,nlohmann::json &member,NetworkSummaryInfo &info)
{
waitForReady();
@@ -285,7 +285,7 @@ inline bool RethinkDB::get(const uint64_t networkId,nlohmann::json &network,cons
return true;
}
-inline bool RethinkDB::get(const uint64_t networkId,nlohmann::json &network,std::vector<nlohmann::json> &members)
+bool RethinkDB::get(const uint64_t networkId,nlohmann::json &network,std::vector<nlohmann::json> &members)
{
waitForReady();
@@ -306,7 +306,7 @@ inline bool RethinkDB::get(const uint64_t networkId,nlohmann::json &network,std:
return true;
}
-inline bool RethinkDB::summary(const uint64_t networkId,NetworkSummaryInfo &info)
+bool RethinkDB::summary(const uint64_t networkId,NetworkSummaryInfo &info)
{
waitForReady();
@@ -337,7 +337,7 @@ void RethinkDB::networks(std::vector<uint64_t> &networks)
void RethinkDB::save(const nlohmann::json &record)
{
waitForReady();
- _commitQueue.post(std::unique_ptr<nlohmann::json>(new nlohmann::json(record)));
+ _commitQueue.post(new nlohmann::json(record));
}
void RethinkDB::eraseNetwork(const uint64_t networkId)
@@ -345,23 +345,23 @@ void RethinkDB::eraseNetwork(const uint64_t networkId)
char tmp2[24];
waitForReady();
Utils::hex(networkId,tmp2);
- json tmp;
- tmp["id"] = tmp2;
- tmp["objtype"] = "delete_network"; // pseudo-type, tells thread to delete network
- _commitQueue.post(std::unique_ptr<nlohmann::json>(new nlohmann::json(tmp)));
+ json *tmp = new json();
+ (*tmp)["id"] = tmp2;
+ (*tmp)["objtype"] = "delete_network"; // pseudo-type, tells thread to delete network
+ _commitQueue.post(tmp);
}
void RethinkDB::eraseMember(const uint64_t networkId,const uint64_t memberId)
{
char tmp2[24];
- json tmp;
+ json *tmp = new json();
waitForReady();
Utils::hex(networkId,tmp2);
- tmp["nwid"] = tmp2;
+ (*tmp)["nwid"] = tmp2;
Utils::hex10(memberId,tmp2);
- tmp["id"] = tmp2;
- tmp["objtype"] = "delete_member"; // pseudo-type, tells thread to delete network
- _commitQueue.post(std::unique_ptr<nlohmann::json>(new nlohmann::json(tmp)));
+ (*tmp)["id"] = tmp2;
+ (*tmp)["objtype"] = "delete_member"; // pseudo-type, tells thread to delete network
+ _commitQueue.post(tmp);
}
void RethinkDB::_memberChanged(nlohmann::json &old,nlohmann::json &member)
@@ -511,14 +511,4 @@ void RethinkDB::_networkChanged(nlohmann::json &old,nlohmann::json &network)
} // namespace ZeroTier
-/*
-int main(int argc,char **argv)
-{
- ZeroTier::RethinkDB db(ZeroTier::Address(0x8056c2e21cULL),"10.6.6.188",28015,"ztc","");
- db.waitForReady();
- printf("ready.\n");
- pause();
-}
-*/
-
#endif // ZT_CONTROLLER_USE_RETHINKDB
diff --git a/controller/RethinkDB.hpp b/controller/RethinkDB.hpp
index cb6c061e..9e65521d 100644
--- a/controller/RethinkDB.hpp
+++ b/controller/RethinkDB.hpp
@@ -33,6 +33,7 @@
#include <unordered_map>
#include <unordered_set>
#include <vector>
+#include <atomic>
#include "../ext/json/json.hpp"
@@ -135,7 +136,7 @@ private:
std::unordered_multimap< uint64_t,uint64_t > _networkByMember;
mutable std::mutex _networks_l;
- BlockingQueue< std::unique_ptr<nlohmann::json> > _commitQueue;
+ BlockingQueue< nlohmann::json * > _commitQueue;
std::thread _commitThread[ZT_CONTROLLER_RETHINKDB_COMMIT_THREADS];
mutable std::mutex _readyLock; // locked until ready