From 48a579ae496a9a969ea0011031f25e0a51c1fc7d Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Tue, 17 Sep 2013 12:18:46 -0700 Subject: [PATCH 01/10] first cut at domain server config support --- domain-server/src/main.cpp | 41 +++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/domain-server/src/main.cpp b/domain-server/src/main.cpp index 044ea0b369..843044b83d 100644 --- a/domain-server/src/main.cpp +++ b/domain-server/src/main.cpp @@ -27,7 +27,10 @@ #include #include +#include #include +#include +#include #include @@ -45,6 +48,7 @@ const int NODE_COUNT_STAT_INTERVAL_MSECS = 5000; QMutex assignmentQueueMutex; std::deque assignmentQueue; +QMap configMap; unsigned char* addNodeToBroadcastPacket(unsigned char* currentPosition, Node* nodeToAdd) { *currentPosition++ = nodeToAdd->getType(); @@ -58,7 +62,7 @@ unsigned char* addNodeToBroadcastPacket(unsigned char* currentPosition, Node* no } static int mongooseRequestHandler(struct mg_connection *conn) { - const struct mg_request_info *ri = mg_get_request_info(conn); + const struct mg_request_info* ri = mg_get_request_info(conn); if (strcmp(ri->uri, "/assignment") == 0 && strcmp(ri->request_method, "POST") == 0) { // return a 200 @@ -66,6 +70,37 @@ static int mongooseRequestHandler(struct mg_connection *conn) { // upload the file mg_upload(conn, "/tmp"); + return 1; + } else if (strncmp(ri->uri, "/config", strlen("/config")) == 0 && strcmp(ri->request_method, "GET") == 0) { + + // Let's split up the URL into it's pieces so we can service it + QString uri(ri->uri); + QString delimiterPattern("/"); + QStringList uriParts = uri.split(delimiterPattern); + + QString configGuid = uriParts[2]; + + // first part should be empty + // second part should be "config" + // third part should be a guid, and therefore should not be empty + if (!uriParts[0].isEmpty() || uriParts[1] != "config" || configGuid.isEmpty()) { + mg_printf(conn, "%s", "HTTP/1.0 400 Bad Request\r\nContent-Type: text/plain\r\n\r\nInvalid parameters."); + return 1; + } + + // assuming the request format was valid, look up the guid in our configs + if (!::configMap.contains(configGuid)) { + mg_printf(conn, "%s", "HTTP/1.0 404 Not Found\r\nContent-Type: text/plain\r\n\r\nInvalid config GUID."); + return 1; + } + + const char * configPayload = configMap[configGuid].toLocal8Bit().data(); + + // return a 200 + mg_printf(conn, "%s", "HTTP/1.0 200 OK\r\n\r\n"); + // return the configuration "payload" + mg_printf(conn, "%s", configPayload); + return 1; } else { // have mongoose process this request from the document_root @@ -157,13 +192,13 @@ int main(int argc, const char* argv[]) { localSocket.sin_addr.s_addr = serverLocalAddress; // setup the mongoose web server - struct mg_context *ctx; + struct mg_context* ctx; struct mg_callbacks callbacks = {}; QString documentRoot = QString("%1/resources/web").arg(QCoreApplication::applicationDirPath()); // list of options. Last element must be NULL. - const char *options[] = {"listening_ports", "8080", + const char* options[] = {"listening_ports", "8080", "document_root", documentRoot.toStdString().c_str(), NULL}; callbacks.begin_request = mongooseRequestHandler; From 4932c3266fa09b0fede12f09c5498c27aae34baf Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Tue, 17 Sep 2013 13:22:09 -0700 Subject: [PATCH 02/10] moving to Assignment payload style implementation --- domain-server/src/main.cpp | 48 ++++++++----------------------- libraries/shared/src/Assignment.h | 8 ++++++ 2 files changed, 20 insertions(+), 36 deletions(-) diff --git a/domain-server/src/main.cpp b/domain-server/src/main.cpp index ab837a0abe..fb2869c327 100644 --- a/domain-server/src/main.cpp +++ b/domain-server/src/main.cpp @@ -48,7 +48,6 @@ const int NODE_COUNT_STAT_INTERVAL_MSECS = 5000; QMutex assignmentQueueMutex; std::deque assignmentQueue; -QMap configMap; unsigned char* addNodeToBroadcastPacket(unsigned char* currentPosition, Node* nodeToAdd) { *currentPosition++ = nodeToAdd->getType(); @@ -70,37 +69,6 @@ static int mongooseRequestHandler(struct mg_connection *conn) { // upload the file mg_upload(conn, "/tmp"); - return 1; - } else if (strncmp(ri->uri, "/config", strlen("/config")) == 0 && strcmp(ri->request_method, "GET") == 0) { - - // Let's split up the URL into it's pieces so we can service it - QString uri(ri->uri); - QString delimiterPattern("/"); - QStringList uriParts = uri.split(delimiterPattern); - - QString configGuid = uriParts[2]; - - // first part should be empty - // second part should be "config" - // third part should be a guid, and therefore should not be empty - if (!uriParts[0].isEmpty() || uriParts[1] != "config" || configGuid.isEmpty()) { - mg_printf(conn, "%s", "HTTP/1.0 400 Bad Request\r\nContent-Type: text/plain\r\n\r\nInvalid parameters."); - return 1; - } - - // assuming the request format was valid, look up the guid in our configs - if (!::configMap.contains(configGuid)) { - mg_printf(conn, "%s", "HTTP/1.0 404 Not Found\r\nContent-Type: text/plain\r\n\r\nInvalid config GUID."); - return 1; - } - - const char * configPayload = configMap[configGuid].toLocal8Bit().data(); - - // return a 200 - mg_printf(conn, "%s", "HTTP/1.0 200 OK\r\n\r\n"); - // return the configuration "payload" - mg_printf(conn, "%s", configPayload); - return 1; } else { // have mongoose process this request from the document_root @@ -166,7 +134,7 @@ int main(int argc, const char* argv[]) { in_addr_t serverLocalAddress = getLocalAddress(); nodeList->startSilentNodeRemovalThread(); - + timeval lastStatSendTime = {}; const char ASSIGNMENT_SERVER_OPTION[] = "-a"; @@ -194,6 +162,15 @@ int main(int argc, const char* argv[]) { Assignment voxelServerAssignment(Assignment::CreateCommand, Assignment::VoxelServerType, Assignment::LocalLocation); + + // Handle Domain/Voxel Server configuration command line arguments + const char VOXEL_CONFIG_OPTION[] = "--voxelServerConfig"; + const char* voxelServerConfig = getCmdOption(argc, argv, VOXEL_CONFIG_OPTION); + if (voxelServerConfig) { + qDebug("Reading Voxel Server Configuration.\n"); + qDebug() << " config: " << voxelServerConfig << "\n"; + voxelServerAssignment.setDataPayload((unsigned char*)voxelServerConfig, strlen(voxelServerConfig) + 1); + } // construct a local socket to send with our created assignments to the global AS sockaddr_in localSocket = {}; @@ -249,10 +226,9 @@ int main(int argc, const char* argv[]) { } } const int MIN_VOXEL_SERVER_CHECKS = 10; - if (checkForVoxelServerAttempt > MIN_VOXEL_SERVER_CHECKS && - voxelServerCount == 0 && + if (checkForVoxelServerAttempt > MIN_VOXEL_SERVER_CHECKS && voxelServerCount == 0 && std::find(::assignmentQueue.begin(), ::assignmentQueue.end(), &voxelServerAssignment) == ::assignmentQueue.end()) { - qDebug("Missing a Voxel Server and assignment not in queue. Adding.\n"); + qDebug("Missing a voxel server and assignment not in queue. Adding.\n"); ::assignmentQueue.push_front(&voxelServerAssignment); } checkForVoxelServerAttempt++; diff --git a/libraries/shared/src/Assignment.h b/libraries/shared/src/Assignment.h index 59e2c45db7..1f0431187a 100644 --- a/libraries/shared/src/Assignment.h +++ b/libraries/shared/src/Assignment.h @@ -15,6 +15,8 @@ #include "NodeList.h" +const int MAX_PAYLOAD_SIZE = 1024; + /// Holds information used for request, creation, and deployment of assignments class Assignment { public: @@ -65,6 +67,10 @@ public: const sockaddr* getAttachedLocalSocket() { return _attachedLocalSocket; } void setAttachedLocalSocket(const sockaddr* attachedLocalSocket); + + unsigned char* getDataPayload() { return _dataPayload; } + int getDataPayloadSize() { return _dataPayloadSize; } + void setDataPayload(unsigned char* data, int length) { memcpy(_dataPayload, data, length); _dataPayloadSize = length; } /// Packs the assignment to the passed buffer /// \param buffer the buffer in which to pack the assignment @@ -83,6 +89,8 @@ private: sockaddr* _attachedLocalSocket; /// pointer to a local socket that relates to assignment, depends on direction timeval _time; /// time the assignment was created (set in constructor) int _numberOfInstances; /// the number of instances of this assignment + unsigned char _dataPayload[MAX_PAYLOAD_SIZE]; + int _dataPayloadSize; }; QDebug operator<<(QDebug debug, const Assignment &assignment); From 386250cff8fe7ee263436645b5b7da6e62803f15 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Tue, 17 Sep 2013 13:41:04 -0700 Subject: [PATCH 03/10] remove hacked payloads --- libraries/shared/src/Assignment.cpp | 2 +- libraries/shared/src/Assignment.h | 8 -------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/libraries/shared/src/Assignment.cpp b/libraries/shared/src/Assignment.cpp index d794495c29..cad644652e 100644 --- a/libraries/shared/src/Assignment.cpp +++ b/libraries/shared/src/Assignment.cpp @@ -140,7 +140,7 @@ int Assignment::packToBuffer(unsigned char* buffer) { numPackedBytes += packSocket(buffer + numPackedBytes, socketToPack); } - + return numPackedBytes; } diff --git a/libraries/shared/src/Assignment.h b/libraries/shared/src/Assignment.h index 1f0431187a..adcbf32d2a 100644 --- a/libraries/shared/src/Assignment.h +++ b/libraries/shared/src/Assignment.h @@ -15,8 +15,6 @@ #include "NodeList.h" -const int MAX_PAYLOAD_SIZE = 1024; - /// Holds information used for request, creation, and deployment of assignments class Assignment { public: @@ -68,10 +66,6 @@ public: const sockaddr* getAttachedLocalSocket() { return _attachedLocalSocket; } void setAttachedLocalSocket(const sockaddr* attachedLocalSocket); - unsigned char* getDataPayload() { return _dataPayload; } - int getDataPayloadSize() { return _dataPayloadSize; } - void setDataPayload(unsigned char* data, int length) { memcpy(_dataPayload, data, length); _dataPayloadSize = length; } - /// Packs the assignment to the passed buffer /// \param buffer the buffer in which to pack the assignment /// \return number of bytes packed into buffer @@ -89,8 +83,6 @@ private: sockaddr* _attachedLocalSocket; /// pointer to a local socket that relates to assignment, depends on direction timeval _time; /// time the assignment was created (set in constructor) int _numberOfInstances; /// the number of instances of this assignment - unsigned char _dataPayload[MAX_PAYLOAD_SIZE]; - int _dataPayloadSize; }; QDebug operator<<(QDebug debug, const Assignment &assignment); From 2388cfc8e07bd7491bdb8da14f613707b4cc5221 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Tue, 17 Sep 2013 14:33:31 -0700 Subject: [PATCH 04/10] first cut at making VoxelServer class run with configuration or standalone --- assignment-client/src/main.cpp | 12 +++++++++++- domain-server/src/main.cpp | 2 +- libraries/voxel-server-library/src/VoxelServer.cpp | 14 ++++++++------ libraries/voxel-server-library/src/VoxelServer.h | 14 ++++++++------ voxel-server/src/main.cpp | 10 ++++++---- 5 files changed, 34 insertions(+), 18 deletions(-) diff --git a/assignment-client/src/main.cpp b/assignment-client/src/main.cpp index 76fb99839a..f287e1066e 100644 --- a/assignment-client/src/main.cpp +++ b/assignment-client/src/main.cpp @@ -32,6 +32,7 @@ pid_t* childForks = NULL; sockaddr_in customAssignmentSocket = {}; int numForks = 0; Assignment::Type overiddenAssignmentType = Assignment::AllTypes; +std::vector voxelServers; void childClient() { // this is one of the child forks or there is a single assignment client, continue assignment-client execution @@ -100,7 +101,9 @@ void childClient() { } else if (deployedAssignment.getType() == Assignment::AvatarMixerType) { AvatarMixer::run(); } else if (deployedAssignment.getType() == Assignment::VoxelServerType) { - VoxelServer::run(); + VoxelServer* voxelServer = new VoxelServer(); + ::voxelServers.push_back(voxelServer); + voxelServer->run((const char*)deployedAssignment.getPayload()); } else { // figure out the URL for the script for this agent assignment QString scriptURLString("http://%1:8080/assignment/%2"); @@ -162,6 +165,13 @@ void sigchldHandler(int sig) { } } } + + // cleanup voxelServers + for (int i = 0; i < ::voxelServers.size(); i++) { + VoxelServer* voxelServer = ::voxelServers[i]; + delete voxelServer; + } + } void parentMonitor() { diff --git a/domain-server/src/main.cpp b/domain-server/src/main.cpp index fb2869c327..ec7a4a8897 100644 --- a/domain-server/src/main.cpp +++ b/domain-server/src/main.cpp @@ -169,7 +169,7 @@ int main(int argc, const char* argv[]) { if (voxelServerConfig) { qDebug("Reading Voxel Server Configuration.\n"); qDebug() << " config: " << voxelServerConfig << "\n"; - voxelServerAssignment.setDataPayload((unsigned char*)voxelServerConfig, strlen(voxelServerConfig) + 1); + voxelServerAssignment.setPayload((uchar*)voxelServerConfig, strlen(voxelServerConfig) + 1); } // construct a local socket to send with our created assignments to the global AS diff --git a/libraries/voxel-server-library/src/VoxelServer.cpp b/libraries/voxel-server-library/src/VoxelServer.cpp index b239a180d9..d2c9613619 100644 --- a/libraries/voxel-server-library/src/VoxelServer.cpp +++ b/libraries/voxel-server-library/src/VoxelServer.cpp @@ -63,22 +63,24 @@ VoxelPersistThread* voxelPersistThread = NULL; pthread_mutex_t treeLock; NodeWatcher nodeWatcher; // used to cleanup AGENT data when agents are killed -int VoxelServer::_argc = 0; -const char** VoxelServer::_argv = NULL; -bool VoxelServer::_dontKillOnMissingDomain = false; - void attachVoxelNodeDataToNode(Node* newNode) { if (newNode->getLinkedData() == NULL) { newNode->setLinkedData(new VoxelNodeData(newNode)); } } +VoxelServer::VoxelServer() { + _argc = 0; + _argv = NULL; + _dontKillOnMissingDomain = false; +} + void VoxelServer::setArguments(int argc, char** argv) { _argc = argc; _argv = const_cast(argv); } -void VoxelServer::setupDomainAndPort(const char* domain, int port) { +void VoxelServer::setupStandAlone(const char* domain, int port) { NodeList::createInstance(NODE_TYPE_VOXEL_SERVER, port); // Handle Local Domain testing with the --local command line @@ -98,7 +100,7 @@ void VoxelServer::setupDomainAndPort(const char* domain, int port) { } //int main(int argc, const char * argv[]) { -void VoxelServer::run() { +void VoxelServer::run(const char* configuration) { pthread_mutex_init(&::treeLock, NULL); qInstallMessageHandler(sharedMessageHandler); diff --git a/libraries/voxel-server-library/src/VoxelServer.h b/libraries/voxel-server-library/src/VoxelServer.h index d51870dbb1..6739f4cfeb 100644 --- a/libraries/voxel-server-library/src/VoxelServer.h +++ b/libraries/voxel-server-library/src/VoxelServer.h @@ -12,23 +12,25 @@ /// Handles assignments of type VoxelServer - sending voxels to various clients. class VoxelServer { public: + VoxelServer(); + /// runs the voxel server assignment - static void run(); + void run(const char* configuration = NULL); /// allows setting of run arguments - static void setArguments(int argc, char** argv); + void setArguments(int argc, char** argv); /// when VoxelServer class is used by voxel-server stand alone executable it calls this to specify the domain /// and port it is handling. When called by assignment-client, this is not needed because assignment-client /// handles ports and domains automatically. /// \param const char* domain domain name, IP address, or local to specify the domain the voxel server is serving /// \param int port port the voxel server will listen on - static void setupDomainAndPort(const char* domain, int port); + void setupStandAlone(const char* domain, int port); private: - static int _argc; - static const char** _argv; - static bool _dontKillOnMissingDomain; + int _argc; + const char** _argv; + bool _dontKillOnMissingDomain; }; diff --git a/voxel-server/src/main.cpp b/voxel-server/src/main.cpp index f854df84cf..4d82c43343 100644 --- a/voxel-server/src/main.cpp +++ b/voxel-server/src/main.cpp @@ -29,17 +29,19 @@ int main(int argc, const char * argv[]) { } printf("portParameter=%s listenPort=%d\n", portParameter, listenPort); } + + VoxelServer ourVoxelServer; if (wantLocalDomain) { - VoxelServer::setupDomainAndPort(local, listenPort); + ourVoxelServer.setupStandAlone(local, listenPort); } else { if (domainIP) { - VoxelServer::setupDomainAndPort(domainIP, listenPort); + ourVoxelServer.setupStandAlone(domainIP, listenPort); } } - VoxelServer::setArguments(argc, const_cast(argv)); - VoxelServer::run(); + ourVoxelServer.setArguments(argc, const_cast(argv)); + ourVoxelServer.run(); } From e86b4f2d8d835e494bd3f2a7aed591516900e7b4 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Tue, 17 Sep 2013 15:47:29 -0700 Subject: [PATCH 05/10] moving VoxelServer globals to member variables --- .../src/VoxelNodeData.cpp | 13 +- .../voxel-server-library/src/VoxelNodeData.h | 4 + .../src/VoxelSendThread.cpp | 53 ++--- .../src/VoxelSendThread.h | 4 +- .../voxel-server-library/src/VoxelServer.cpp | 203 +++++++++--------- .../voxel-server-library/src/VoxelServer.h | 48 +++++ .../src/VoxelServerPacketProcessor.cpp | 30 +-- .../src/VoxelServerPacketProcessor.h | 9 + .../src/VoxelServerState.h | 53 ----- 9 files changed, 216 insertions(+), 201 deletions(-) delete mode 100644 libraries/voxel-server-library/src/VoxelServerState.h diff --git a/libraries/voxel-server-library/src/VoxelNodeData.cpp b/libraries/voxel-server-library/src/VoxelNodeData.cpp index bdc1de69dc..43d87c2f89 100644 --- a/libraries/voxel-server-library/src/VoxelNodeData.cpp +++ b/libraries/voxel-server-library/src/VoxelNodeData.cpp @@ -28,14 +28,17 @@ VoxelNodeData::VoxelNodeData(Node* owningNode) : _voxelPacket = new unsigned char[MAX_VOXEL_PACKET_SIZE]; _voxelPacketAt = _voxelPacket; resetVoxelPacket(); - +} + +void VoxelNodeData::initializeVoxelSendThread(VoxelServer* voxelServer) { // Create voxel sending thread... uint16_t nodeID = getOwningNode()->getNodeID(); - _voxelSendThread = new VoxelSendThread(nodeID); + _voxelSendThread = new VoxelSendThread(nodeID, voxelServer); _voxelSendThread->initialize(true); } + void VoxelNodeData::resetVoxelPacket() { // If we're moving, and the client asked for low res, then we force monochrome, otherwise, use // the clients requested color state. @@ -57,8 +60,10 @@ void VoxelNodeData::writeToPacket(unsigned char* buffer, int bytes) { VoxelNodeData::~VoxelNodeData() { delete[] _voxelPacket; - _voxelSendThread->terminate(); - delete _voxelSendThread; + if (_voxelSendThread) { + _voxelSendThread->terminate(); + delete _voxelSendThread; + } } bool VoxelNodeData::updateCurrentViewFrustum() { diff --git a/libraries/voxel-server-library/src/VoxelNodeData.h b/libraries/voxel-server-library/src/VoxelNodeData.h index e3abb7f415..85ebe2ebb7 100644 --- a/libraries/voxel-server-library/src/VoxelNodeData.h +++ b/libraries/voxel-server-library/src/VoxelNodeData.h @@ -19,6 +19,7 @@ #include class VoxelSendThread; +class VoxelServer; class VoxelNodeData : public AvatarData { public: @@ -65,6 +66,9 @@ public: VoxelSceneStats stats; + void initializeVoxelSendThread(VoxelServer* voxelServer); + bool isVoxelSendThreadInitalized() { return _voxelSendThread; } + private: VoxelNodeData(const VoxelNodeData &); VoxelNodeData& operator= (const VoxelNodeData&); diff --git a/libraries/voxel-server-library/src/VoxelSendThread.cpp b/libraries/voxel-server-library/src/VoxelSendThread.cpp index b9bb861349..ac2c56d2d3 100644 --- a/libraries/voxel-server-library/src/VoxelSendThread.cpp +++ b/libraries/voxel-server-library/src/VoxelSendThread.cpp @@ -16,10 +16,11 @@ extern EnvironmentData environmentData[3]; #include "VoxelSendThread.h" #include "VoxelServer.h" -#include "VoxelServerState.h" +#include "VoxelServerConsts.h" -VoxelSendThread::VoxelSendThread(uint16_t nodeID) : - _nodeID(nodeID) { +VoxelSendThread::VoxelSendThread(uint16_t nodeID, VoxelServer* myServer) : + _nodeID(nodeID), + _myServer(myServer) { } bool VoxelSendThread::process() { @@ -35,7 +36,7 @@ bool VoxelSendThread::process() { // Sometimes the node data has not yet been linked, in which case we can't really do anything if (nodeData) { bool viewFrustumChanged = nodeData->updateCurrentViewFrustum(); - if (::debugVoxelSending) { + if (_myServer->wantsDebugVoxelSending()) { printf("nodeData->updateCurrentViewFrustum() changed=%s\n", debug::valueOf(viewFrustumChanged)); } deepestLevelVoxelDistributor(node, nodeData, viewFrustumChanged); @@ -47,7 +48,7 @@ bool VoxelSendThread::process() { if (usecToSleep > 0) { usleep(usecToSleep); } else { - if (::debugVoxelSending) { + if (_myServer->wantsDebugVoxelSending()) { std::cout << "Last send took too much time, not sleeping!\n"; } } @@ -94,7 +95,7 @@ void VoxelSendThread::handlePacketSend(Node* node, VoxelNodeData* nodeData, int& /// Version of voxel distributor that sends the deepest LOD level at once void VoxelSendThread::deepestLevelVoxelDistributor(Node* node, VoxelNodeData* nodeData, bool viewFrustumChanged) { - pthread_mutex_lock(&::treeLock); + _myServer->lockTree(); int truePacketsSent = 0; int trueBytesSent = 0; @@ -113,7 +114,7 @@ void VoxelSendThread::deepestLevelVoxelDistributor(Node* node, VoxelNodeData* no if (wantColor != nodeData->getCurrentPacketIsColor()) { if (nodeData->isPacketWaiting()) { - if (::debugVoxelSending) { + if (_myServer->wantsDebugVoxelSending()) { printf("wantColor=%s --- SENDING PARTIAL PACKET! nodeData->getCurrentPacketIsColor()=%s\n", debug::valueOf(wantColor), debug::valueOf(nodeData->getCurrentPacketIsColor())); } @@ -121,7 +122,7 @@ void VoxelSendThread::deepestLevelVoxelDistributor(Node* node, VoxelNodeData* no handlePacketSend(node, nodeData, trueBytesSent, truePacketsSent); } else { - if (::debugVoxelSending) { + if (_myServer->wantsDebugVoxelSending()) { printf("wantColor=%s --- FIXING HEADER! nodeData->getCurrentPacketIsColor()=%s\n", debug::valueOf(wantColor), debug::valueOf(nodeData->getCurrentPacketIsColor())); } @@ -129,7 +130,7 @@ void VoxelSendThread::deepestLevelVoxelDistributor(Node* node, VoxelNodeData* no } } - if (::debugVoxelSending) { + if (_myServer->wantsDebugVoxelSending()) { printf("wantColor=%s getCurrentPacketIsColor()=%s, viewFrustumChanged=%s, getWantLowResMoving()=%s\n", debug::valueOf(wantColor), debug::valueOf(nodeData->getCurrentPacketIsColor()), debug::valueOf(viewFrustumChanged), debug::valueOf(nodeData->getWantLowResMoving())); @@ -137,7 +138,7 @@ void VoxelSendThread::deepestLevelVoxelDistributor(Node* node, VoxelNodeData* no const ViewFrustum* lastViewFrustum = wantDelta ? &nodeData->getLastKnownViewFrustum() : NULL; - if (::debugVoxelSending) { + if (_myServer->wantsDebugVoxelSending()) { printf("deepestLevelVoxelDistributor() viewFrustumChanged=%s, nodeBag.isEmpty=%s, viewSent=%s\n", debug::valueOf(viewFrustumChanged), debug::valueOf(nodeData->nodeBag.isEmpty()), debug::valueOf(nodeData->getViewSent()) @@ -148,7 +149,7 @@ void VoxelSendThread::deepestLevelVoxelDistributor(Node* node, VoxelNodeData* no // the current view frustum for things to send. if (viewFrustumChanged || nodeData->nodeBag.isEmpty()) { uint64_t now = usecTimestampNow(); - if (::debugVoxelSending) { + if (_myServer->wantsDebugVoxelSending()) { printf("(viewFrustumChanged=%s || nodeData->nodeBag.isEmpty() =%s)...\n", debug::valueOf(viewFrustumChanged), debug::valueOf(nodeData->nodeBag.isEmpty())); if (nodeData->getLastTimeBagEmpty() > 0) { @@ -166,7 +167,7 @@ void VoxelSendThread::deepestLevelVoxelDistributor(Node* node, VoxelNodeData* no // if our view has changed, we need to reset these things... if (viewFrustumChanged) { - if (::dumpVoxelsOnMove) { + if (_myServer->wantDumpVoxelsOnMove()) { nodeData->nodeBag.deleteAll(); } nodeData->map.erase(); @@ -180,7 +181,7 @@ void VoxelSendThread::deepestLevelVoxelDistributor(Node* node, VoxelNodeData* no nodeData->stats.sceneCompleted(); - if (::displayVoxelStats) { + if (_myServer->wantDisplayVoxelStats()) { nodeData->stats.printDebugDetails(); } @@ -191,10 +192,10 @@ void VoxelSendThread::deepestLevelVoxelDistributor(Node* node, VoxelNodeData* no if (isFullScene) { nodeData->nodeBag.deleteAll(); } - nodeData->stats.sceneStarted(isFullScene, viewFrustumChanged, ::serverTree.rootNode, ::jurisdiction); + nodeData->stats.sceneStarted(isFullScene, viewFrustumChanged, _myServer->getServerTree().rootNode, _myServer->getJurisdiction()); // This is the start of "resending" the scene. - nodeData->nodeBag.insert(serverTree.rootNode); + nodeData->nodeBag.insert(_myServer->getServerTree().rootNode); } // If we have something in our nodeBag, then turn them into packets and send them out... @@ -203,8 +204,8 @@ void VoxelSendThread::deepestLevelVoxelDistributor(Node* node, VoxelNodeData* no int packetsSentThisInterval = 0; uint64_t start = usecTimestampNow(); - bool shouldSendEnvironments = ::sendEnvironments && shouldDo(ENVIRONMENT_SEND_INTERVAL_USECS, VOXEL_SEND_INTERVAL_USECS); - while (packetsSentThisInterval < PACKETS_PER_CLIENT_PER_INTERVAL - (shouldSendEnvironments ? 1 : 0)) { + bool shouldSendEnvironments = _myServer->wantSendEnvironments() && shouldDo(ENVIRONMENT_SEND_INTERVAL_USECS, VOXEL_SEND_INTERVAL_USECS); + while (packetsSentThisInterval < _myServer->getPacketsPerClientPerInterval() - (shouldSendEnvironments ? 1 : 0)) { // Check to see if we're taking too long, and if so bail early... uint64_t now = usecTimestampNow(); long elapsedUsec = (now - start); @@ -212,7 +213,7 @@ void VoxelSendThread::deepestLevelVoxelDistributor(Node* node, VoxelNodeData* no long usecRemaining = (VOXEL_SEND_INTERVAL_USECS - elapsedUsec); if (elapsedUsecPerPacket + SENDING_TIME_TO_SPARE > usecRemaining) { - if (::debugVoxelSending) { + if (_myServer->wantsDebugVoxelSending()) { printf("packetLoop() usecRemaining=%ld bailing early took %ld usecs to generate %d bytes in %d packets (%ld usec avg), %d nodes still to send\n", usecRemaining, elapsedUsec, trueBytesSent, truePacketsSent, elapsedUsecPerPacket, nodeData->nodeBag.count()); @@ -234,10 +235,10 @@ void VoxelSendThread::deepestLevelVoxelDistributor(Node* node, VoxelNodeData* no WANT_EXISTS_BITS, DONT_CHOP, wantDelta, lastViewFrustum, wantOcclusionCulling, coverageMap, boundaryLevelAdjust, nodeData->getLastTimeBagEmpty(), - isFullScene, &nodeData->stats, ::jurisdiction); + isFullScene, &nodeData->stats, _myServer->getJurisdiction()); nodeData->stats.encodeStarted(); - bytesWritten = serverTree.encodeTreeBitstream(subTree, _tempOutputBuffer, MAX_VOXEL_PACKET_SIZE - 1, + bytesWritten = _myServer->getServerTree().encodeTreeBitstream(subTree, _tempOutputBuffer, MAX_VOXEL_PACKET_SIZE - 1, nodeData->nodeBag, params); nodeData->stats.encodeStopped(); @@ -254,17 +255,17 @@ void VoxelSendThread::deepestLevelVoxelDistributor(Node* node, VoxelNodeData* no handlePacketSend(node, nodeData, trueBytesSent, truePacketsSent); nodeData->resetVoxelPacket(); } - packetsSentThisInterval = PACKETS_PER_CLIENT_PER_INTERVAL; // done for now, no nodes left + packetsSentThisInterval = _myServer->getPacketsPerClientPerInterval(); // done for now, no nodes left } } // send the environment packet if (shouldSendEnvironments) { int numBytesPacketHeader = populateTypeAndVersion(_tempOutputBuffer, PACKET_TYPE_ENVIRONMENT_DATA); int envPacketLength = numBytesPacketHeader; - int environmentsToSend = ::sendMinimalEnvironment ? 1 : sizeof(environmentData) / sizeof(EnvironmentData); + int environmentsToSend = _myServer->getSendMinimalEnvironment() ? 1 : _myServer->getEnvironmentDataCount(); for (int i = 0; i < environmentsToSend; i++) { - envPacketLength += environmentData[i].getBroadcastData(_tempOutputBuffer + envPacketLength); + envPacketLength += _myServer->getEnvironmentData(i)->getBroadcastData(_tempOutputBuffer + envPacketLength); } NodeList::getInstance()->getNodeSocket()->send(node->getActiveSocket(), _tempOutputBuffer, envPacketLength); @@ -283,7 +284,7 @@ void VoxelSendThread::deepestLevelVoxelDistributor(Node* node, VoxelNodeData* no printf("WARNING! packetLoop() took %d milliseconds to generate %d bytes in %d packets, %d nodes still to send\n", elapsedmsec, trueBytesSent, truePacketsSent, nodeData->nodeBag.count()); } - } else if (::debugVoxelSending) { + } else if (_myServer->wantsDebugVoxelSending()) { printf("packetLoop() took %d milliseconds to generate %d bytes in %d packets, %d nodes still to send\n", elapsedmsec, trueBytesSent, truePacketsSent, nodeData->nodeBag.count()); } @@ -293,7 +294,7 @@ void VoxelSendThread::deepestLevelVoxelDistributor(Node* node, VoxelNodeData* no if (nodeData->nodeBag.isEmpty()) { nodeData->updateLastKnownViewFrustum(); nodeData->setViewSent(true); - if (::debugVoxelSending) { + if (_myServer->wantsDebugVoxelSending()) { nodeData->map.printStats(); } nodeData->map.erase(); // It would be nice if we could save this, and only reset it when the view frustum changes @@ -301,6 +302,6 @@ void VoxelSendThread::deepestLevelVoxelDistributor(Node* node, VoxelNodeData* no } // end if bag wasn't empty, and so we sent stuff... - pthread_mutex_unlock(&::treeLock); + _myServer->unlockTree(); } diff --git a/libraries/voxel-server-library/src/VoxelSendThread.h b/libraries/voxel-server-library/src/VoxelSendThread.h index fa6c1460c7..37824abedb 100644 --- a/libraries/voxel-server-library/src/VoxelSendThread.h +++ b/libraries/voxel-server-library/src/VoxelSendThread.h @@ -16,17 +16,19 @@ #include #include #include "VoxelNodeData.h" +#include "VoxelServer.h" /// Threaded processor for sending voxel packets to a single client class VoxelSendThread : public virtual GenericThread { public: - VoxelSendThread(uint16_t nodeID); + VoxelSendThread(uint16_t nodeID, VoxelServer* myServer); protected: /// Implements generic processing behavior for this thread. virtual bool process(); private: uint16_t _nodeID; + VoxelServer* _myServer; void handlePacketSend(Node* node, VoxelNodeData* nodeData, int& trueBytesSent, int& truePacketsSent); void deepestLevelVoxelDistributor(Node* node, VoxelNodeData* nodeData, bool viewFrustumChanged); diff --git a/libraries/voxel-server-library/src/VoxelServer.cpp b/libraries/voxel-server-library/src/VoxelServer.cpp index d2c9613619..9625926ebd 100644 --- a/libraries/voxel-server-library/src/VoxelServer.cpp +++ b/libraries/voxel-server-library/src/VoxelServer.cpp @@ -14,7 +14,6 @@ #include #include #include -#include #include #include "VoxelNodeData.h" #include @@ -23,11 +22,6 @@ #include #include -#include "NodeWatcher.h" -#include "VoxelPersistThread.h" -#include "VoxelSendThread.h" -#include "VoxelServerPacketProcessor.h" - #ifdef _WIN32 #include "Syssocket.h" #include "Systime.h" @@ -38,30 +32,10 @@ #endif #include "VoxelServer.h" -#include "VoxelServerState.h" +#include "VoxelServerConsts.h" const char* LOCAL_VOXELS_PERSIST_FILE = "resources/voxels.svo"; const char* VOXELS_PERSIST_FILE = "/etc/highfidelity/voxel-server/resources/voxels.svo"; -char voxelPersistFilename[MAX_FILENAME_LENGTH]; -int PACKETS_PER_CLIENT_PER_INTERVAL = 10; -VoxelTree serverTree(true); // this IS a reaveraging tree -bool wantVoxelPersist = true; -bool wantLocalDomain = false; -bool debugVoxelSending = false; -bool shouldShowAnimationDebug = false; -bool displayVoxelStats = false; -bool debugVoxelReceiving = false; -bool sendEnvironments = true; -bool sendMinimalEnvironment = false; -bool dumpVoxelsOnMove = false; -EnvironmentData environmentData[3]; -int receivedPacketCount = 0; -JurisdictionMap* jurisdiction = NULL; -JurisdictionSender* jurisdictionSender = NULL; -VoxelServerPacketProcessor* voxelServerPacketProcessor = NULL; -VoxelPersistThread* voxelPersistThread = NULL; -pthread_mutex_t treeLock; -NodeWatcher nodeWatcher; // used to cleanup AGENT data when agents are killed void attachVoxelNodeDataToNode(Node* newNode) { if (newNode->getLinkedData() == NULL) { @@ -69,10 +43,29 @@ void attachVoxelNodeDataToNode(Node* newNode) { } } -VoxelServer::VoxelServer() { +VoxelServer::VoxelServer() : + _serverTree(true) +{ _argc = 0; _argv = NULL; _dontKillOnMissingDomain = false; + + _PACKETS_PER_CLIENT_PER_INTERVAL = 10; + _wantVoxelPersist = true; + _wantLocalDomain = false; + _debugVoxelSending = false; + _shouldShowAnimationDebug = false; + _displayVoxelStats = false; + _debugVoxelReceiving = false; + _sendEnvironments = true; + _sendMinimalEnvironment = false; + _dumpVoxelsOnMove = false; + _jurisdiction = NULL; + _jurisdictionSender = NULL; + _voxelServerPacketProcessor = NULL; + _voxelPersistThread = NULL; + + } void VoxelServer::setArguments(int argc, char** argv) { @@ -85,8 +78,8 @@ void VoxelServer::setupStandAlone(const char* domain, int port) { // Handle Local Domain testing with the --local command line const char* local = "--local"; - ::wantLocalDomain = strcmp(domain, local) == 0; - if (::wantLocalDomain) { + _wantLocalDomain = strcmp(domain, local) == 0; + if (_wantLocalDomain) { printf("Local Domain MODE!\n"); NodeList::getInstance()->setDomainIPToLocalhost(); } else { @@ -101,7 +94,7 @@ void VoxelServer::setupStandAlone(const char* domain, int port) { //int main(int argc, const char * argv[]) { void VoxelServer::run(const char* configuration) { - pthread_mutex_init(&::treeLock, NULL); + pthread_mutex_init(&_treeLock, NULL); qInstallMessageHandler(sharedMessageHandler); @@ -111,7 +104,7 @@ void VoxelServer::run(const char* configuration) { printf("jurisdictionFile=%s\n", jurisdictionFile); printf("about to readFromFile().... jurisdictionFile=%s\n", jurisdictionFile); - jurisdiction = new JurisdictionMap(jurisdictionFile); + _jurisdiction = new JurisdictionMap(jurisdictionFile); printf("after readFromFile().... jurisdictionFile=%s\n", jurisdictionFile); } else { const char* JURISDICTION_ROOT = "--jurisdictionRoot"; @@ -127,28 +120,28 @@ void VoxelServer::run(const char* configuration) { } if (jurisdictionRoot || jurisdictionEndNodes) { - ::jurisdiction = new JurisdictionMap(jurisdictionRoot, jurisdictionEndNodes); + _jurisdiction = new JurisdictionMap(jurisdictionRoot, jurisdictionEndNodes); } } // should we send environments? Default is yes, but this command line suppresses sending const char* DUMP_VOXELS_ON_MOVE = "--dumpVoxelsOnMove"; - ::dumpVoxelsOnMove = cmdOptionExists(_argc, _argv, DUMP_VOXELS_ON_MOVE); - printf("dumpVoxelsOnMove=%s\n", debug::valueOf(::dumpVoxelsOnMove)); + _dumpVoxelsOnMove = cmdOptionExists(_argc, _argv, DUMP_VOXELS_ON_MOVE); + printf("dumpVoxelsOnMove=%s\n", debug::valueOf(_dumpVoxelsOnMove)); // should we send environments? Default is yes, but this command line suppresses sending const char* DONT_SEND_ENVIRONMENTS = "--dontSendEnvironments"; bool dontSendEnvironments = getCmdOption(_argc, _argv, DONT_SEND_ENVIRONMENTS); if (dontSendEnvironments) { printf("Sending environments suppressed...\n"); - ::sendEnvironments = false; + _sendEnvironments = false; } else { // should we send environments? Default is yes, but this command line suppresses sending const char* MINIMAL_ENVIRONMENT = "--MinimalEnvironment"; - ::sendMinimalEnvironment = getCmdOption(_argc, _argv, MINIMAL_ENVIRONMENT); - printf("Using Minimal Environment=%s\n", debug::valueOf(::sendMinimalEnvironment)); + _sendMinimalEnvironment = getCmdOption(_argc, _argv, MINIMAL_ENVIRONMENT); + printf("Using Minimal Environment=%s\n", debug::valueOf(_sendMinimalEnvironment)); } - printf("Sending environments=%s\n", debug::valueOf(::sendEnvironments)); + printf("Sending environments=%s\n", debug::valueOf(_sendEnvironments)); NodeList* nodeList = NodeList::getInstance(); nodeList->setOwnerType(NODE_TYPE_VOXEL_SERVER); @@ -156,72 +149,72 @@ void VoxelServer::run(const char* configuration) { setvbuf(stdout, NULL, _IOLBF, 0); // tell our NodeList about our desire to get notifications - nodeList->addHook(&nodeWatcher); + nodeList->addHook(&_nodeWatcher); nodeList->linkedDataCreateCallback = &attachVoxelNodeDataToNode; nodeList->startSilentNodeRemovalThread(); srand((unsigned)time(0)); const char* DISPLAY_VOXEL_STATS = "--displayVoxelStats"; - ::displayVoxelStats = getCmdOption(_argc, _argv, DISPLAY_VOXEL_STATS); - printf("displayVoxelStats=%s\n", debug::valueOf(::displayVoxelStats)); + _displayVoxelStats = getCmdOption(_argc, _argv, DISPLAY_VOXEL_STATS); + printf("displayVoxelStats=%s\n", debug::valueOf(_displayVoxelStats)); const char* DEBUG_VOXEL_SENDING = "--debugVoxelSending"; - ::debugVoxelSending = getCmdOption(_argc, _argv, DEBUG_VOXEL_SENDING); - printf("debugVoxelSending=%s\n", debug::valueOf(::debugVoxelSending)); + _debugVoxelSending = getCmdOption(_argc, _argv, DEBUG_VOXEL_SENDING); + printf("debugVoxelSending=%s\n", debug::valueOf(_debugVoxelSending)); const char* DEBUG_VOXEL_RECEIVING = "--debugVoxelReceiving"; - ::debugVoxelReceiving = getCmdOption(_argc, _argv, DEBUG_VOXEL_RECEIVING); - printf("debugVoxelReceiving=%s\n", debug::valueOf(::debugVoxelReceiving)); + _debugVoxelReceiving = getCmdOption(_argc, _argv, DEBUG_VOXEL_RECEIVING); + printf("debugVoxelReceiving=%s\n", debug::valueOf(_debugVoxelReceiving)); const char* WANT_ANIMATION_DEBUG = "--shouldShowAnimationDebug"; - ::shouldShowAnimationDebug = getCmdOption(_argc, _argv, WANT_ANIMATION_DEBUG); - printf("shouldShowAnimationDebug=%s\n", debug::valueOf(::shouldShowAnimationDebug)); + _shouldShowAnimationDebug = getCmdOption(_argc, _argv, WANT_ANIMATION_DEBUG); + printf("shouldShowAnimationDebug=%s\n", debug::valueOf(_shouldShowAnimationDebug)); // By default we will voxel persist, if you want to disable this, then pass in this parameter const char* NO_VOXEL_PERSIST = "--NoVoxelPersist"; if ( getCmdOption(_argc, _argv, NO_VOXEL_PERSIST)) { - ::wantVoxelPersist = false; + _wantVoxelPersist = false; } - printf("wantVoxelPersist=%s\n", debug::valueOf(::wantVoxelPersist)); + printf("wantVoxelPersist=%s\n", debug::valueOf(_wantVoxelPersist)); // if we want Voxel Persistence, load the local file now... bool persistantFileRead = false; - if (::wantVoxelPersist) { + if (_wantVoxelPersist) { // Check to see if the user passed in a command line option for setting packet send rate const char* VOXELS_PERSIST_FILENAME = "--voxelsPersistFilename"; const char* voxelsPersistFilenameParameter = getCmdOption(_argc, _argv, VOXELS_PERSIST_FILENAME); if (voxelsPersistFilenameParameter) { - strcpy(voxelPersistFilename, voxelsPersistFilenameParameter); + strcpy(_voxelPersistFilename, voxelsPersistFilenameParameter); } else { - //strcpy(voxelPersistFilename, ::wantLocalDomain ? LOCAL_VOXELS_PERSIST_FILE : VOXELS_PERSIST_FILE); - strcpy(voxelPersistFilename, LOCAL_VOXELS_PERSIST_FILE); + //strcpy(voxelPersistFilename, _wantLocalDomain ? LOCAL_VOXELS_PERSIST_FILE : VOXELS_PERSIST_FILE); + strcpy(_voxelPersistFilename, LOCAL_VOXELS_PERSIST_FILE); } - printf("loading voxels from file: %s...\n", voxelPersistFilename); + printf("loading voxels from file: %s...\n", _voxelPersistFilename); - persistantFileRead = ::serverTree.readFromSVOFile(::voxelPersistFilename); + persistantFileRead = _serverTree.readFromSVOFile(_voxelPersistFilename); if (persistantFileRead) { - PerformanceWarning warn(::shouldShowAnimationDebug, - "persistVoxelsWhenDirty() - reaverageVoxelColors()", ::shouldShowAnimationDebug); + PerformanceWarning warn(_shouldShowAnimationDebug, + "persistVoxelsWhenDirty() - reaverageVoxelColors()", _shouldShowAnimationDebug); // after done inserting all these voxels, then reaverage colors - serverTree.reaverageVoxelColors(serverTree.rootNode); + _serverTree.reaverageVoxelColors(_serverTree.rootNode); printf("Voxels reAveraged\n"); } - ::serverTree.clearDirtyBit(); // the tree is clean since we just loaded it + _serverTree.clearDirtyBit(); // the tree is clean since we just loaded it printf("DONE loading voxels from file... fileRead=%s\n", debug::valueOf(persistantFileRead)); - unsigned long nodeCount = ::serverTree.rootNode->getSubTreeNodeCount(); - unsigned long internalNodeCount = ::serverTree.rootNode->getSubTreeInternalNodeCount(); - unsigned long leafNodeCount = ::serverTree.rootNode->getSubTreeLeafNodeCount(); + unsigned long nodeCount = _serverTree.rootNode->getSubTreeNodeCount(); + unsigned long internalNodeCount = _serverTree.rootNode->getSubTreeInternalNodeCount(); + unsigned long leafNodeCount = _serverTree.rootNode->getSubTreeLeafNodeCount(); printf("Nodes after loading scene %lu nodes %lu internal %lu leaves\n", nodeCount, internalNodeCount, leafNodeCount); // now set up VoxelPersistThread - ::voxelPersistThread = new VoxelPersistThread(&::serverTree, ::voxelPersistFilename); - if (::voxelPersistThread) { - ::voxelPersistThread->initialize(true); + _voxelPersistThread = new VoxelPersistThread(&_serverTree, _voxelPersistFilename); + if (_voxelPersistThread) { + _voxelPersistThread->initialize(true); } } @@ -230,32 +223,32 @@ void VoxelServer::run(const char* configuration) { const char* INPUT_FILE = "-i"; const char* voxelsFilename = getCmdOption(_argc, _argv, INPUT_FILE); if (voxelsFilename) { - serverTree.readFromSVOFile(voxelsFilename); + _serverTree.readFromSVOFile(voxelsFilename); } // Check to see if the user passed in a command line option for setting packet send rate const char* PACKETS_PER_SECOND = "--packetsPerSecond"; const char* packetsPerSecond = getCmdOption(_argc, _argv, PACKETS_PER_SECOND); if (packetsPerSecond) { - PACKETS_PER_CLIENT_PER_INTERVAL = atoi(packetsPerSecond)/INTERVALS_PER_SECOND; - if (PACKETS_PER_CLIENT_PER_INTERVAL < 1) { - PACKETS_PER_CLIENT_PER_INTERVAL = 1; + _PACKETS_PER_CLIENT_PER_INTERVAL = atoi(packetsPerSecond)/INTERVALS_PER_SECOND; + if (_PACKETS_PER_CLIENT_PER_INTERVAL < 1) { + _PACKETS_PER_CLIENT_PER_INTERVAL = 1; } - printf("packetsPerSecond=%s PACKETS_PER_CLIENT_PER_INTERVAL=%d\n", packetsPerSecond, PACKETS_PER_CLIENT_PER_INTERVAL); + printf("packetsPerSecond=%s PACKETS_PER_CLIENT_PER_INTERVAL=%d\n", packetsPerSecond, _PACKETS_PER_CLIENT_PER_INTERVAL); } // for now, initialize the environments with fixed values - environmentData[1].setID(1); - environmentData[1].setGravity(1.0f); - environmentData[1].setAtmosphereCenter(glm::vec3(0.5, 0.5, (0.25 - 0.06125)) * (float)TREE_SCALE); - environmentData[1].setAtmosphereInnerRadius(0.030625f * TREE_SCALE); - environmentData[1].setAtmosphereOuterRadius(0.030625f * TREE_SCALE * 1.05f); - environmentData[2].setID(2); - environmentData[2].setGravity(1.0f); - environmentData[2].setAtmosphereCenter(glm::vec3(0.5f, 0.5f, 0.5f) * (float)TREE_SCALE); - environmentData[2].setAtmosphereInnerRadius(0.1875f * TREE_SCALE); - environmentData[2].setAtmosphereOuterRadius(0.1875f * TREE_SCALE * 1.05f); - environmentData[2].setScatteringWavelengths(glm::vec3(0.475f, 0.570f, 0.650f)); // swaps red and blue + _environmentData[1].setID(1); + _environmentData[1].setGravity(1.0f); + _environmentData[1].setAtmosphereCenter(glm::vec3(0.5, 0.5, (0.25 - 0.06125)) * (float)TREE_SCALE); + _environmentData[1].setAtmosphereInnerRadius(0.030625f * TREE_SCALE); + _environmentData[1].setAtmosphereOuterRadius(0.030625f * TREE_SCALE * 1.05f); + _environmentData[2].setID(2); + _environmentData[2].setGravity(1.0f); + _environmentData[2].setAtmosphereCenter(glm::vec3(0.5f, 0.5f, 0.5f) * (float)TREE_SCALE); + _environmentData[2].setAtmosphereInnerRadius(0.1875f * TREE_SCALE); + _environmentData[2].setAtmosphereOuterRadius(0.1875f * TREE_SCALE * 1.05f); + _environmentData[2].setScatteringWavelengths(glm::vec3(0.475f, 0.570f, 0.650f)); // swaps red and blue sockaddr senderAddress; @@ -265,15 +258,15 @@ void VoxelServer::run(const char* configuration) { timeval lastDomainServerCheckIn = {}; // set up our jurisdiction broadcaster... - ::jurisdictionSender = new JurisdictionSender(::jurisdiction); - if (::jurisdictionSender) { - ::jurisdictionSender->initialize(true); + _jurisdictionSender = new JurisdictionSender(_jurisdiction); + if (_jurisdictionSender) { + _jurisdictionSender->initialize(true); } // set up our VoxelServerPacketProcessor - ::voxelServerPacketProcessor = new VoxelServerPacketProcessor(); - if (::voxelServerPacketProcessor) { - ::voxelServerPacketProcessor->initialize(true); + _voxelServerPacketProcessor = new VoxelServerPacketProcessor(this); + if (_voxelServerPacketProcessor) { + _voxelServerPacketProcessor->initialize(true); } // loop to send to nodes requesting data @@ -312,40 +305,40 @@ void VoxelServer::run(const char* configuration) { } else if (packetData[0] == PACKET_TYPE_DOMAIN) { NodeList::getInstance()->processNodeData(&senderAddress, packetData, packetLength); } else if (packetData[0] == PACKET_TYPE_VOXEL_JURISDICTION_REQUEST) { - if (::jurisdictionSender) { - ::jurisdictionSender->queueReceivedPacket(senderAddress, packetData, packetLength); + if (_jurisdictionSender) { + _jurisdictionSender->queueReceivedPacket(senderAddress, packetData, packetLength); } - } else if (::voxelServerPacketProcessor) { - ::voxelServerPacketProcessor->queueReceivedPacket(senderAddress, packetData, packetLength); + } else if (_voxelServerPacketProcessor) { + _voxelServerPacketProcessor->queueReceivedPacket(senderAddress, packetData, packetLength); } else { printf("unknown packet ignored... packetData[0]=%c\n", packetData[0]); } } } - if (::jurisdiction) { - delete ::jurisdiction; + if (_jurisdiction) { + delete _jurisdiction; } - if (::jurisdictionSender) { - ::jurisdictionSender->terminate(); - delete ::jurisdictionSender; + if (_jurisdictionSender) { + _jurisdictionSender->terminate(); + delete _jurisdictionSender; } - if (::voxelServerPacketProcessor) { - ::voxelServerPacketProcessor->terminate(); - delete ::voxelServerPacketProcessor; + if (_voxelServerPacketProcessor) { + _voxelServerPacketProcessor->terminate(); + delete _voxelServerPacketProcessor; } - if (::voxelPersistThread) { - ::voxelPersistThread->terminate(); - delete ::voxelPersistThread; + if (_voxelPersistThread) { + _voxelPersistThread->terminate(); + delete _voxelPersistThread; } // tell our NodeList we're done with notifications - nodeList->removeHook(&nodeWatcher); + nodeList->removeHook(&_nodeWatcher); - pthread_mutex_destroy(&::treeLock); + pthread_mutex_destroy(&_treeLock); } diff --git a/libraries/voxel-server-library/src/VoxelServer.h b/libraries/voxel-server-library/src/VoxelServer.h index 6739f4cfeb..923bc5139c 100644 --- a/libraries/voxel-server-library/src/VoxelServer.h +++ b/libraries/voxel-server-library/src/VoxelServer.h @@ -9,6 +9,14 @@ #ifndef __voxel_server__VoxelServer__ #define __voxel_server__VoxelServer__ +#include + +#include "NodeWatcher.h" +#include "VoxelPersistThread.h" +#include "VoxelSendThread.h" +#include "VoxelServerConsts.h" +#include "VoxelServerPacketProcessor.h" + /// Handles assignments of type VoxelServer - sending voxels to various clients. class VoxelServer { public: @@ -27,10 +35,50 @@ public: /// \param int port port the voxel server will listen on void setupStandAlone(const char* domain, int port); + bool wantsDebugVoxelSending() const { return _debugVoxelSending; } + bool wantsDebugVoxelReceiving() const { return _debugVoxelReceiving; } + bool wantShowAnimationDebug() const { return _shouldShowAnimationDebug; } + bool wantSendEnvironments() const { return _sendEnvironments; } + bool wantDumpVoxelsOnMove() const { return _dumpVoxelsOnMove; } + bool wantDisplayVoxelStats() const { return _displayVoxelStats; } + + VoxelTree& getServerTree() { return _serverTree; } + JurisdictionMap* getJurisdiction() { return _jurisdiction; } + + void lockTree() { pthread_mutex_lock(&_treeLock); } + void unlockTree() { pthread_mutex_unlock(&_treeLock); } + + int getPacketsPerClientPerInterval() const { return _PACKETS_PER_CLIENT_PER_INTERVAL; } + bool getSendMinimalEnvironment() const { return _sendMinimalEnvironment; } + EnvironmentData* getEnvironmentData(int i) { return &_environmentData[i]; } + int getEnvironmentDataCount() const { return sizeof(_environmentData)/sizeof(EnvironmentData); } + private: int _argc; const char** _argv; bool _dontKillOnMissingDomain; + + char _voxelPersistFilename[MAX_FILENAME_LENGTH]; + int _PACKETS_PER_CLIENT_PER_INTERVAL; + VoxelTree _serverTree; // this IS a reaveraging tree + bool _wantVoxelPersist; + bool _wantLocalDomain; + bool _debugVoxelSending; + bool _shouldShowAnimationDebug; + bool _displayVoxelStats; + bool _debugVoxelReceiving; + bool _sendEnvironments; + bool _sendMinimalEnvironment; + bool _dumpVoxelsOnMove; + JurisdictionMap* _jurisdiction; + JurisdictionSender* _jurisdictionSender; + VoxelServerPacketProcessor* _voxelServerPacketProcessor; + VoxelPersistThread* _voxelPersistThread; + pthread_mutex_t _treeLock; + EnvironmentData _environmentData[3]; + + NodeWatcher _nodeWatcher; // used to cleanup AGENT data when agents are killed + }; diff --git a/libraries/voxel-server-library/src/VoxelServerPacketProcessor.cpp b/libraries/voxel-server-library/src/VoxelServerPacketProcessor.cpp index d283296e6f..9b79ae121a 100644 --- a/libraries/voxel-server-library/src/VoxelServerPacketProcessor.cpp +++ b/libraries/voxel-server-library/src/VoxelServerPacketProcessor.cpp @@ -12,33 +12,39 @@ #include #include "VoxelServer.h" -#include "VoxelServerState.h" +#include "VoxelServerConsts.h" #include "VoxelServerPacketProcessor.h" +VoxelServerPacketProcessor::VoxelServerPacketProcessor(VoxelServer* myServer) : + _myServer(myServer), + _receivedPacketCount(0) { +} + + void VoxelServerPacketProcessor::processPacket(sockaddr& senderAddress, unsigned char* packetData, ssize_t packetLength) { int numBytesPacketHeader = numBytesForPacketHeader(packetData); if (packetData[0] == PACKET_TYPE_SET_VOXEL || packetData[0] == PACKET_TYPE_SET_VOXEL_DESTRUCTIVE) { bool destructive = (packetData[0] == PACKET_TYPE_SET_VOXEL_DESTRUCTIVE); - PerformanceWarning warn(::shouldShowAnimationDebug, + PerformanceWarning warn(_myServer->wantShowAnimationDebug(), destructive ? "PACKET_TYPE_SET_VOXEL_DESTRUCTIVE" : "PACKET_TYPE_SET_VOXEL", - ::shouldShowAnimationDebug); + _myServer->wantShowAnimationDebug()); - ::receivedPacketCount++; + _receivedPacketCount++; unsigned short int itemNumber = (*((unsigned short int*)(packetData + numBytesPacketHeader))); - if (::shouldShowAnimationDebug) { + if (_myServer->wantShowAnimationDebug()) { printf("got %s - command from client receivedBytes=%ld itemNumber=%d\n", destructive ? "PACKET_TYPE_SET_VOXEL_DESTRUCTIVE" : "PACKET_TYPE_SET_VOXEL", packetLength, itemNumber); } - if (::debugVoxelReceiving) { + if (_myServer->wantsDebugVoxelReceiving()) { printf("got %s - %d command from client receivedBytes=%ld itemNumber=%d\n", destructive ? "PACKET_TYPE_SET_VOXEL_DESTRUCTIVE" : "PACKET_TYPE_SET_VOXEL", - ::receivedPacketCount, packetLength, itemNumber); + _receivedPacketCount, packetLength, itemNumber); } int atByte = numBytesPacketHeader + sizeof(itemNumber); unsigned char* voxelData = (unsigned char*)&packetData[atByte]; @@ -48,7 +54,7 @@ void VoxelServerPacketProcessor::processPacket(sockaddr& senderAddress, unsigned int voxelDataSize = bytesRequiredForCodeLength(octets) + COLOR_SIZE_IN_BYTES; int voxelCodeSize = bytesRequiredForCodeLength(octets); - if (::shouldShowAnimationDebug) { + if (_myServer->wantShowAnimationDebug()) { int red = voxelData[voxelCodeSize + 0]; int green = voxelData[voxelCodeSize + 1]; int blue = voxelData[voxelCodeSize + 2]; @@ -58,7 +64,7 @@ void VoxelServerPacketProcessor::processPacket(sockaddr& senderAddress, unsigned delete[] vertices; } - serverTree.readCodeColorBufferToTree(voxelData, destructive); + _myServer->getServerTree().readCodeColorBufferToTree(voxelData, destructive); // skip to next voxelData += voxelDataSize; atByte += voxelDataSize; @@ -73,9 +79,9 @@ void VoxelServerPacketProcessor::processPacket(sockaddr& senderAddress, unsigned } else if (packetData[0] == PACKET_TYPE_ERASE_VOXEL) { // Send these bits off to the VoxelTree class to process them - pthread_mutex_lock(&::treeLock); - ::serverTree.processRemoveVoxelBitstream((unsigned char*)packetData, packetLength); - pthread_mutex_unlock(&::treeLock); + _myServer->lockTree(); + _myServer->getServerTree().processRemoveVoxelBitstream((unsigned char*)packetData, packetLength); + _myServer->unlockTree(); // Make sure our Node and NodeList knows we've heard from this node. Node* node = NodeList::getInstance()->nodeWithAddress(&senderAddress); diff --git a/libraries/voxel-server-library/src/VoxelServerPacketProcessor.h b/libraries/voxel-server-library/src/VoxelServerPacketProcessor.h index caad7bf240..8ef316bd23 100644 --- a/libraries/voxel-server-library/src/VoxelServerPacketProcessor.h +++ b/libraries/voxel-server-library/src/VoxelServerPacketProcessor.h @@ -12,11 +12,20 @@ #define __voxel_server__VoxelServerPacketProcessor__ #include +class VoxelServer; /// Handles processing of incoming network packets for the voxel-server. As with other ReceivedPacketProcessor classes /// the user is responsible for reading inbound packets and adding them to the processing queue by calling queueReceivedPacket() class VoxelServerPacketProcessor : public ReceivedPacketProcessor { + +public: + VoxelServerPacketProcessor(VoxelServer* myServer); + protected: virtual void processPacket(sockaddr& senderAddress, unsigned char* packetData, ssize_t packetLength); + +private: + VoxelServer* _myServer; + int _receivedPacketCount; }; #endif // __voxel_server__VoxelServerPacketProcessor__ diff --git a/libraries/voxel-server-library/src/VoxelServerState.h b/libraries/voxel-server-library/src/VoxelServerState.h deleted file mode 100644 index 2d00d4a046..0000000000 --- a/libraries/voxel-server-library/src/VoxelServerState.h +++ /dev/null @@ -1,53 +0,0 @@ -// VoxelServer.h -// voxel-server -// -// Created by Brad Hefta-Gaub on 8/21/13 -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. -// -// - -#ifndef __voxel_server__VoxelServerState__ -#define __voxel_server__VoxelServerState__ - -#include -#include // for MAX_PACKET_SIZE -#include -#include - -#include "VoxelServerPacketProcessor.h" - - -const int MAX_FILENAME_LENGTH = 1024; -const int VOXEL_SIZE_BYTES = 3 + (3 * sizeof(float)); -const int VOXELS_PER_PACKET = (MAX_PACKET_SIZE - 1) / VOXEL_SIZE_BYTES; -const int MIN_BRIGHTNESS = 64; -const float DEATH_STAR_RADIUS = 4.0; -const float MAX_CUBE = 0.05f; -const int VOXEL_SEND_INTERVAL_USECS = 17 * 1000; // approximately 60fps -const int SENDING_TIME_TO_SPARE = 5 * 1000; // usec of sending interval to spare for calculating voxels -const int INTERVALS_PER_SECOND = 1000 * 1000 / VOXEL_SEND_INTERVAL_USECS; -const int MAX_VOXEL_TREE_DEPTH_LEVELS = 4; -const int ENVIRONMENT_SEND_INTERVAL_USECS = 1000000; - -extern const char* LOCAL_VOXELS_PERSIST_FILE; -extern const char* VOXELS_PERSIST_FILE; -extern char voxelPersistFilename[MAX_FILENAME_LENGTH]; -extern int PACKETS_PER_CLIENT_PER_INTERVAL; - -extern VoxelTree serverTree; // this IS a reaveraging tree -extern bool wantVoxelPersist; -extern bool wantLocalDomain; -extern bool debugVoxelSending; -extern bool shouldShowAnimationDebug; -extern bool displayVoxelStats; -extern bool debugVoxelReceiving; -extern bool sendEnvironments; -extern bool sendMinimalEnvironment; -extern bool dumpVoxelsOnMove; -extern int receivedPacketCount; -extern JurisdictionMap* jurisdiction; -extern JurisdictionSender* jurisdictionSender; -extern VoxelServerPacketProcessor* voxelServerPacketProcessor; -extern pthread_mutex_t treeLock; - -#endif // __voxel_server__VoxelServerState__ From 2b9290a9e3fc74853500562d55969233a1119084 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Tue, 17 Sep 2013 15:47:39 -0700 Subject: [PATCH 06/10] moving VoxelServer globals to member variables --- .../src/VoxelServerConsts.h | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 libraries/voxel-server-library/src/VoxelServerConsts.h diff --git a/libraries/voxel-server-library/src/VoxelServerConsts.h b/libraries/voxel-server-library/src/VoxelServerConsts.h new file mode 100644 index 0000000000..b70e460a58 --- /dev/null +++ b/libraries/voxel-server-library/src/VoxelServerConsts.h @@ -0,0 +1,31 @@ +// VoxelServerConsts.h +// voxel-server +// +// Created by Brad Hefta-Gaub on 8/21/13 +// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// +// + +#ifndef __voxel_server__VoxelServerConsts__ +#define __voxel_server__VoxelServerConsts__ + +#include +#include // for MAX_PACKET_SIZE +#include +#include + +#include "VoxelServerPacketProcessor.h" + + +const int MAX_FILENAME_LENGTH = 1024; +const int VOXEL_SIZE_BYTES = 3 + (3 * sizeof(float)); +const int VOXELS_PER_PACKET = (MAX_PACKET_SIZE - 1) / VOXEL_SIZE_BYTES; +const int VOXEL_SEND_INTERVAL_USECS = 17 * 1000; // approximately 60fps +const int SENDING_TIME_TO_SPARE = 5 * 1000; // usec of sending interval to spare for calculating voxels +const int INTERVALS_PER_SECOND = 1000 * 1000 / VOXEL_SEND_INTERVAL_USECS; +const int ENVIRONMENT_SEND_INTERVAL_USECS = 1000000; + +extern const char* LOCAL_VOXELS_PERSIST_FILE; +extern const char* VOXELS_PERSIST_FILE; + +#endif // __voxel_server__VoxelServerConsts__ From f75b480b0ec3b7bfef5e82e884f8082fb3b70bbd Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Tue, 17 Sep 2013 16:40:39 -0700 Subject: [PATCH 07/10] correctly hook up VoxelSendThread in VoxelNodeData --- libraries/voxel-server-library/src/VoxelServer.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libraries/voxel-server-library/src/VoxelServer.cpp b/libraries/voxel-server-library/src/VoxelServer.cpp index fed5bdd869..a6b1f80f49 100644 --- a/libraries/voxel-server-library/src/VoxelServer.cpp +++ b/libraries/voxel-server-library/src/VoxelServer.cpp @@ -64,7 +64,6 @@ VoxelServer::VoxelServer(Assignment::Command command, Assignment::Location locat _jurisdictionSender = NULL; _voxelServerPacketProcessor = NULL; _voxelPersistThread = NULL; - } VoxelServer::VoxelServer(const unsigned char* dataBuffer, int numBytes) : Assignment(dataBuffer, numBytes) { @@ -301,6 +300,12 @@ void VoxelServer::run() { nodeID); NodeList::getInstance()->updateNodeWithData(node, packetData, packetLength); + + VoxelNodeData* nodeData = (VoxelNodeData*) node->getLinkedData(); + if (nodeData && !nodeData->isVoxelSendThreadInitalized()) { + nodeData->initializeVoxelSendThread(this); + } + } else if (packetData[0] == PACKET_TYPE_PING) { // If the packet is a ping, let processNodeData handle it. NodeList::getInstance()->processNodeData(&senderAddress, packetData, packetLength); From 5f9ac5c28090f1d925d64e0808ff2c5bb176f729 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Tue, 17 Sep 2013 17:19:39 -0700 Subject: [PATCH 08/10] second constructor --- .../voxel-server-library/src/VoxelServer.cpp | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/libraries/voxel-server-library/src/VoxelServer.cpp b/libraries/voxel-server-library/src/VoxelServer.cpp index a6b1f80f49..9ff2c44066 100644 --- a/libraries/voxel-server-library/src/VoxelServer.cpp +++ b/libraries/voxel-server-library/src/VoxelServer.cpp @@ -66,7 +66,26 @@ VoxelServer::VoxelServer(Assignment::Command command, Assignment::Location locat _voxelPersistThread = NULL; } -VoxelServer::VoxelServer(const unsigned char* dataBuffer, int numBytes) : Assignment(dataBuffer, numBytes) { +VoxelServer::VoxelServer(const unsigned char* dataBuffer, int numBytes) : Assignment(dataBuffer, numBytes), + _serverTree(true) { + _argc = 0; + _argv = NULL; + _dontKillOnMissingDomain = false; + + _PACKETS_PER_CLIENT_PER_INTERVAL = 10; + _wantVoxelPersist = true; + _wantLocalDomain = false; + _debugVoxelSending = false; + _shouldShowAnimationDebug = false; + _displayVoxelStats = false; + _debugVoxelReceiving = false; + _sendEnvironments = true; + _sendMinimalEnvironment = false; + _dumpVoxelsOnMove = false; + _jurisdiction = NULL; + _jurisdictionSender = NULL; + _voxelServerPacketProcessor = NULL; + _voxelPersistThread = NULL; } void VoxelServer::setArguments(int argc, char** argv) { @@ -174,7 +193,7 @@ void VoxelServer::run() { // By default we will voxel persist, if you want to disable this, then pass in this parameter const char* NO_VOXEL_PERSIST = "--NoVoxelPersist"; - if ( getCmdOption(_argc, _argv, NO_VOXEL_PERSIST)) { + if (getCmdOption(_argc, _argv, NO_VOXEL_PERSIST)) { _wantVoxelPersist = false; } printf("wantVoxelPersist=%s\n", debug::valueOf(_wantVoxelPersist)); @@ -253,7 +272,7 @@ void VoxelServer::run() { sockaddr senderAddress; - unsigned char *packetData = new unsigned char[MAX_PACKET_SIZE]; + unsigned char* packetData = new unsigned char[MAX_PACKET_SIZE]; ssize_t packetLength; timeval lastDomainServerCheckIn = {}; @@ -269,7 +288,7 @@ void VoxelServer::run() { if (_voxelServerPacketProcessor) { _voxelServerPacketProcessor->initialize(true); } - + // loop to send to nodes requesting data while (true) { From 1bfd23e3de9dcae65ec86f558f498d8fe1e5d1d3 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Tue, 17 Sep 2013 17:27:20 -0700 Subject: [PATCH 09/10] CR feedback --- domain-server/src/main.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/domain-server/src/main.cpp b/domain-server/src/main.cpp index a4f7b7d6fb..bfef06ad7e 100644 --- a/domain-server/src/main.cpp +++ b/domain-server/src/main.cpp @@ -29,8 +29,6 @@ #include #include #include -#include -#include #include From 3145a543d97d0e7cf1725ee68fd66b06a7fcc0c9 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Tue, 17 Sep 2013 17:34:47 -0700 Subject: [PATCH 10/10] fixed CR feedback --- .../voxel-server-library/src/VoxelServer.cpp | 16 +++++++--------- libraries/voxel-server-library/src/VoxelServer.h | 4 ++-- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/libraries/voxel-server-library/src/VoxelServer.cpp b/libraries/voxel-server-library/src/VoxelServer.cpp index 9ff2c44066..257f9b2640 100644 --- a/libraries/voxel-server-library/src/VoxelServer.cpp +++ b/libraries/voxel-server-library/src/VoxelServer.cpp @@ -50,7 +50,7 @@ VoxelServer::VoxelServer(Assignment::Command command, Assignment::Location locat _argv = NULL; _dontKillOnMissingDomain = false; - _PACKETS_PER_CLIENT_PER_INTERVAL = 10; + _packetsPerClientPerInterval = 10; _wantVoxelPersist = true; _wantLocalDomain = false; _debugVoxelSending = false; @@ -72,7 +72,7 @@ VoxelServer::VoxelServer(const unsigned char* dataBuffer, int numBytes) : Assign _argv = NULL; _dontKillOnMissingDomain = false; - _PACKETS_PER_CLIENT_PER_INTERVAL = 10; + _packetsPerClientPerInterval = 10; _wantVoxelPersist = true; _wantLocalDomain = false; _debugVoxelSending = false; @@ -250,11 +250,11 @@ void VoxelServer::run() { const char* PACKETS_PER_SECOND = "--packetsPerSecond"; const char* packetsPerSecond = getCmdOption(_argc, _argv, PACKETS_PER_SECOND); if (packetsPerSecond) { - _PACKETS_PER_CLIENT_PER_INTERVAL = atoi(packetsPerSecond)/INTERVALS_PER_SECOND; - if (_PACKETS_PER_CLIENT_PER_INTERVAL < 1) { - _PACKETS_PER_CLIENT_PER_INTERVAL = 1; + _packetsPerClientPerInterval = atoi(packetsPerSecond) / INTERVALS_PER_SECOND; + if (_packetsPerClientPerInterval < 1) { + _packetsPerClientPerInterval = 1; } - printf("packetsPerSecond=%s PACKETS_PER_CLIENT_PER_INTERVAL=%d\n", packetsPerSecond, _PACKETS_PER_CLIENT_PER_INTERVAL); + printf("packetsPerSecond=%s PACKETS_PER_CLIENT_PER_INTERVAL=%d\n", packetsPerSecond, _packetsPerClientPerInterval); } // for now, initialize the environments with fixed values @@ -342,9 +342,7 @@ void VoxelServer::run() { } } - if (_jurisdiction) { - delete _jurisdiction; - } + delete _jurisdiction; if (_jurisdictionSender) { _jurisdictionSender->terminate(); diff --git a/libraries/voxel-server-library/src/VoxelServer.h b/libraries/voxel-server-library/src/VoxelServer.h index 3a7d0e5c48..6eb412ea68 100644 --- a/libraries/voxel-server-library/src/VoxelServer.h +++ b/libraries/voxel-server-library/src/VoxelServer.h @@ -53,7 +53,7 @@ public: void lockTree() { pthread_mutex_lock(&_treeLock); } void unlockTree() { pthread_mutex_unlock(&_treeLock); } - int getPacketsPerClientPerInterval() const { return _PACKETS_PER_CLIENT_PER_INTERVAL; } + int getPacketsPerClientPerInterval() const { return _packetsPerClientPerInterval; } bool getSendMinimalEnvironment() const { return _sendMinimalEnvironment; } EnvironmentData* getEnvironmentData(int i) { return &_environmentData[i]; } int getEnvironmentDataCount() const { return sizeof(_environmentData)/sizeof(EnvironmentData); } @@ -64,7 +64,7 @@ private: bool _dontKillOnMissingDomain; char _voxelPersistFilename[MAX_FILENAME_LENGTH]; - int _PACKETS_PER_CLIENT_PER_INTERVAL; + int _packetsPerClientPerInterval; VoxelTree _serverTree; // this IS a reaveraging tree bool _wantVoxelPersist; bool _wantLocalDomain;