From 3149431e1663364674f70e90e55381b44fd3fcc7 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 11 Sep 2013 12:23:15 -0700 Subject: [PATCH] remove notion of pool from assignment-server --- assignment-server/src/main.cpp | 59 +++++++++++++--------------------- 1 file changed, 23 insertions(+), 36 deletions(-) diff --git a/assignment-server/src/main.cpp b/assignment-server/src/main.cpp index 248b9fdc83..73c5d10156 100644 --- a/assignment-server/src/main.cpp +++ b/assignment-server/src/main.cpp @@ -59,43 +59,30 @@ int main(int argc, const char* argv[]) { continue; } - bool eitherHasPool = ((*assignment)->getPool() || requestAssignment.getPool()); - bool bothHavePool = ((*assignment)->getPool() && requestAssignment.getPool()); - - // make sure there is a pool match for the created and requested assignment - // or that neither has a designated pool - if ((eitherHasPool && bothHavePool - && strcmp((*assignment)->getPool(), requestAssignment.getPool()) == 0) - || !eitherHasPool) { - - // check if the requestor is on the same network as the destination for the assignment - if (senderSocket.sin_addr.s_addr == - ((sockaddr_in*) (*assignment)->getAttachedPublicSocket())->sin_addr.s_addr) { - // if this is the case we remove the public socket on the assignment by setting it to NULL - // this ensures the local IP and port sent to the requestor is the local address of destination - (*assignment)->setAttachedPublicSocket(NULL); - } - - - int numAssignmentBytes = (*assignment)->packToBuffer(assignmentPacket + numSendHeaderBytes); - - // send the assignment - serverSocket.send((sockaddr*) &senderSocket, - assignmentPacket, - numSendHeaderBytes + numAssignmentBytes); - - - // delete this assignment now that it has been sent out - delete *assignment; - // remove it from the deque and make the iterator the next assignment - assignmentQueue.erase(assignment); - - // stop looping - we've handed out an assignment - break; - } else { - // push forward the iterator - assignment++; + // check if the requestor is on the same network as the destination for the assignment + if (senderSocket.sin_addr.s_addr == + ((sockaddr_in*) (*assignment)->getAttachedPublicSocket())->sin_addr.s_addr) { + // if this is the case we remove the public socket on the assignment by setting it to NULL + // this ensures the local IP and port sent to the requestor is the local address of destination + (*assignment)->setAttachedPublicSocket(NULL); } + + + int numAssignmentBytes = (*assignment)->packToBuffer(assignmentPacket + numSendHeaderBytes); + + // send the assignment + serverSocket.send((sockaddr*) &senderSocket, + assignmentPacket, + numSendHeaderBytes + numAssignmentBytes); + + + // delete this assignment now that it has been sent out + delete *assignment; + // remove it from the deque and make the iterator the next assignment + assignmentQueue.erase(assignment); + + // stop looping - we've handed out an assignment + break; } } } else if (senderData[0] == PACKET_TYPE_CREATE_ASSIGNMENT && packetVersionMatch(senderData)) {