Linux build fixes, linux build rule for RethinkDB mode controller, also force disable shitty allocators in libstdc++.

This commit is contained in:
Adam Ierymenko 2017-11-03 16:59:36 -04:00
parent d97adc8789
commit b68bca35db
7 changed files with 39 additions and 39 deletions

1
.gitignore vendored
View File

@ -11,6 +11,7 @@
.Apple*
Thumbs.db
@eaDir
._*
# Windows build droppings
/windows/ZeroTierOne.sdf

View File

@ -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 {

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -18,20 +18,20 @@ ONE_OBJS+=osdep/LinuxEthernetTap.o
# Auto-detect miniupnpc and nat-pmp as well and use system libs if present,
# otherwise build into binary as done on Mac and Windows.
ONE_OBJS+=osdep/PortMapper.o
DEFS+=-DZT_USE_MINIUPNPC
override DEFS+=-DZT_USE_MINIUPNPC
MINIUPNPC_IS_NEW_ENOUGH=$(shell grep -sqr '.*define.*MINIUPNPC_VERSION.*"2.."' /usr/include/miniupnpc/miniupnpc.h && echo 1)
ifeq ($(MINIUPNPC_IS_NEW_ENOUGH),1)
DEFS+=-DZT_USE_SYSTEM_MINIUPNPC
override DEFS+=-DZT_USE_SYSTEM_MINIUPNPC
LDLIBS+=-lminiupnpc
else
DEFS+=-DMINIUPNP_STATICLIB -DMINIUPNPC_SET_SOCKET_TIMEOUT -DMINIUPNPC_GET_SRC_ADDR -D_BSD_SOURCE -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 -DOS_STRING=\"Linux\" -DMINIUPNPC_VERSION_STRING=\"2.0\" -DUPNP_VERSION_STRING=\"UPnP/1.1\" -DENABLE_STRNATPMPERR
override DEFS+=-DMINIUPNP_STATICLIB -DMINIUPNPC_SET_SOCKET_TIMEOUT -DMINIUPNPC_GET_SRC_ADDR -D_BSD_SOURCE -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 -DOS_STRING=\"Linux\" -DMINIUPNPC_VERSION_STRING=\"2.0\" -DUPNP_VERSION_STRING=\"UPnP/1.1\" -DENABLE_STRNATPMPERR
ONE_OBJS+=ext/miniupnpc/connecthostport.o ext/miniupnpc/igd_desc_parse.o ext/miniupnpc/minisoap.o ext/miniupnpc/minissdpc.o ext/miniupnpc/miniupnpc.o ext/miniupnpc/miniwget.o ext/miniupnpc/minixml.o ext/miniupnpc/portlistingparse.o ext/miniupnpc/receivedata.o ext/miniupnpc/upnpcommands.o ext/miniupnpc/upnpdev.o ext/miniupnpc/upnperrors.o ext/miniupnpc/upnpreplyparse.o
endif
ifeq ($(wildcard /usr/include/natpmp.h),)
ONE_OBJS+=ext/libnatpmp/natpmp.o ext/libnatpmp/getgateway.o
else
LDLIBS+=-lnatpmp
DEFS+=-DZT_USE_SYSTEM_NATPMP
override DEFS+=-DZT_USE_SYSTEM_NATPMP
endif
# Use bundled http-parser since distribution versions are NOT API-stable or compatible!
@ -39,19 +39,19 @@ endif
ONE_OBJS+=ext/http-parser/http_parser.o
ifeq ($(ZT_SYNOLOGY), 1)
DEFS+=-D__SYNOLOGY__
override DEFS+=-D__SYNOLOGY__
endif
ifeq ($(ZT_QNAP), 1)
DEFS+=-D__QNAP__
override DEFS+=-D__QNAP__
endif
ifeq ($(ZT_TRACE),1)
DEFS+=-DZT_TRACE
override DEFS+=-DZT_TRACE
endif
ifeq ($(ZT_RULES_ENGINE_DEBUGGING),1)
DEFS+=-DZT_RULES_ENGINE_DEBUGGING
override DEFS+=-DZT_RULES_ENGINE_DEBUGGING
endif
ifeq ($(ZT_DEBUG),1)
@ -195,6 +195,9 @@ endif
# Disable software updates by default on Linux since that is normally done with package management
override DEFS+=-DZT_BUILD_PLATFORM=1 -DZT_BUILD_ARCHITECTURE=$(ZT_ARCHITECTURE) -DZT_SOFTWARE_UPDATE_DEFAULT="\"disable\""
# This forces libstdc++ not to include these abominations, especially mt and pool
override DEFS+=-D_MT_ALLOCATOR_H -D_POOL_ALLOCATOR_H -D_EXTPTR_ALLOCATOR_H -D_DEBUG_ALLOCATOR_H
# Static builds, which are currently done for a number of Linux targets
ifeq ($(ZT_STATIC),1)
override LDFLAGS+=-static
@ -263,6 +266,10 @@ realclean: distclean
official-static: FORCE
make -j4 ZT_STATIC=1 LDLIBS=/usr/lib/libjemalloc.a all selftest
central-controller: FORCE
cd ext/librethinkdbxx ; make
make LDLIBS="-ljemalloc ext/librethinkdbxx/build/librethinkdb++.a" DEFS="-DZT_CONTROLLER_USE_RETHINKDB" one
debug: FORCE
make ZT_DEBUG=1 one
make ZT_DEBUG=1 selftest

View File

@ -28,7 +28,7 @@ CORE_OBJS=\
ONE_OBJS=\
controller/EmbeddedNetworkController.o \
controller/JSONDB.o \
controller/RethinkDB.o \
osdep/ManagedRoute.o \
osdep/Http.o \
osdep/OSUtils.o \