From 9260bee653ca3d5e553e3d758f7866603e07e8cc Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 4 Sep 2013 11:13:37 -0700 Subject: [PATCH] add assignment pool passing to DS, cleanup in AS --- assignment-client/src/main.cpp | 11 ++++++----- domain-server/src/main.cpp | 26 ++++++++++++++++++++------ 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/assignment-client/src/main.cpp b/assignment-client/src/main.cpp index f89db0e383..6143f531ca 100644 --- a/assignment-client/src/main.cpp +++ b/assignment-client/src/main.cpp @@ -32,18 +32,19 @@ int main(int argc, char* const argv[]) { const char ALLOWED_PARAMETERS[] = "p::"; const char POOL_PARAMETER_CHAR = 'p'; - char* poolParam = NULL; + char* assignmentPool = NULL; while ((parameter = getopt(argc, argv, ALLOWED_PARAMETERS)) != -1) { - // while we only have one allowed param there is no need to check if this was 'p' if (parameter == POOL_PARAMETER_CHAR) { + // copy the passed assignment pool int poolLength = strlen(optarg); - poolParam = new char[poolLength]; - memcpy(poolParam, optarg, poolLength); + assignmentPool = new char[poolLength]; + memcpy(assignmentPool, optarg, poolLength); } } - Assignment requestAssignment(Assignment::Request, Assignment::All, poolParam); + // create a request assignment, accept all assignments, pass the desired pool (if it exists) + Assignment requestAssignment(Assignment::Request, Assignment::All, assignmentPool); while (true) { if (usecTimestampNow() - usecTimestamp(&lastRequest) >= ASSIGNMENT_REQUEST_INTERVAL_USECS) { diff --git a/domain-server/src/main.cpp b/domain-server/src/main.cpp index c22606ef53..0ea1e8e4e3 100644 --- a/domain-server/src/main.cpp +++ b/domain-server/src/main.cpp @@ -47,14 +47,14 @@ unsigned char* addNodeToBroadcastPacket(unsigned char* currentPosition, Node* no return currentPosition; } -int main(int argc, const char * argv[]) +int main(int argc, char* const argv[]) { NodeList* nodeList = NodeList::createInstance(NODE_TYPE_DOMAIN, DOMAIN_LISTEN_PORT); // If user asks to run in "local" mode then we do NOT replace the IP // with the EC2 IP. Otherwise, we will replace the IP like we used to // this allows developers to run a local domain without recompiling the // domain server - bool isLocalMode = cmdOptionExists(argc, argv, "--local"); + bool isLocalMode = cmdOptionExists(argc, (const char**) argv, "--local"); if (isLocalMode) { printf("NOTE: Running in local mode!\n"); } else { @@ -85,13 +85,27 @@ int main(int argc, const char * argv[]) timeval lastStatSendTime = {}; + // loop the parameters to see if we were passed a pool for assignment + int parameter = -1; + const char ALLOWED_PARAMETERS[] = "p::"; + const char POOL_PARAMETER_CHAR = 'p'; + + char* assignmentPool = NULL; + + while ((parameter = getopt(argc, argv, ALLOWED_PARAMETERS)) != -1) { + if (parameter == POOL_PARAMETER_CHAR) { + // copy the passed assignment pool + int poolLength = strlen(optarg); + assignmentPool = new char[poolLength]; + memcpy(assignmentPool, optarg, poolLength); + } + } + while (true) { if (!nodeList->soloNodeOfType(NODE_TYPE_AUDIO_MIXER)) { - // we don't have an audio mixer, and we know we need one - // so tell that to the assignment server - - Assignment mixerAssignment(Assignment::Create, Assignment::AudioMixer); + // create an assignment to send, ask for an audio mixer, pass the assignment pool if it exists + Assignment mixerAssignment(Assignment::Create, Assignment::AudioMixer, assignmentPool); nodeList->sendAssignment(mixerAssignment); }