mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 06:37:27 +02:00
allow repeated check ins from existing node
This commit is contained in:
parent
0e5c5886b6
commit
e63dfadcde
2 changed files with 33 additions and 6 deletions
|
@ -75,7 +75,7 @@ void DomainServer::civetwebUploadHandler(struct mg_connection *connection, const
|
||||||
}
|
}
|
||||||
|
|
||||||
void DomainServer::nodeAdded(Node* node) {
|
void DomainServer::nodeAdded(Node* node) {
|
||||||
// do nothing - ID is incremented in run()
|
NodeList::getInstance()->increaseNodeID();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DomainServer::nodeKilled(Node* node) {
|
void DomainServer::nodeKilled(Node* node) {
|
||||||
|
@ -83,7 +83,7 @@ void DomainServer::nodeKilled(Node* node) {
|
||||||
if (node->getLinkedData()) {
|
if (node->getLinkedData()) {
|
||||||
Assignment* nodeAssignment = (Assignment*) node->getLinkedData();
|
Assignment* nodeAssignment = (Assignment*) node->getLinkedData();
|
||||||
|
|
||||||
qDebug() << "Adding assignment" << &nodeAssignment << "back to queue.\n";
|
qDebug() << "Adding assignment" << *nodeAssignment << "back to queue.\n";
|
||||||
|
|
||||||
// find this assignment in the static file
|
// find this assignment in the static file
|
||||||
for (int i = 0; i < MAX_STATIC_ASSIGNMENT_FILE_ASSIGNMENTS; i++) {
|
for (int i = 0; i < MAX_STATIC_ASSIGNMENT_FILE_ASSIGNMENTS; i++) {
|
||||||
|
@ -301,6 +301,29 @@ void DomainServer::removeAssignmentFromQueue(Assignment* removableAssignment) {
|
||||||
_assignmentQueueMutex.unlock();
|
_assignmentQueueMutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool DomainServer::checkInWithUUIDMatchesExistingNode(sockaddr* nodePublicSocket,
|
||||||
|
sockaddr* nodeLocalSocket,
|
||||||
|
const uchar* checkInData) {
|
||||||
|
// pull the UUID passed with the check in
|
||||||
|
QUuid checkInUUID = QUuid::fromRfc4122(QByteArray((const char*) checkInData + numBytesForPacketHeader(checkInData) +
|
||||||
|
sizeof(NODE_TYPE),
|
||||||
|
NUM_BYTES_RFC4122_UUID));
|
||||||
|
|
||||||
|
NodeList* nodeList = NodeList::getInstance();
|
||||||
|
|
||||||
|
for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
|
||||||
|
if (node->getLinkedData()
|
||||||
|
&& socketMatch(node->getPublicSocket(), nodePublicSocket)
|
||||||
|
&& socketMatch(node->getLocalSocket(), nodeLocalSocket)
|
||||||
|
&& ((Assignment*) node->getLinkedData())->getUUID() == checkInUUID) {
|
||||||
|
// this is a matching existing node if the public socket, local socket, and UUID match
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void DomainServer::cleanup() {
|
void DomainServer::cleanup() {
|
||||||
_staticAssignmentFile.unmap(_staticAssignmentFileData);
|
_staticAssignmentFile.unmap(_staticAssignmentFileData);
|
||||||
_staticAssignmentFile.close();
|
_staticAssignmentFile.close();
|
||||||
|
@ -374,16 +397,18 @@ int DomainServer::run() {
|
||||||
Assignment* matchingStaticAssignment = NULL;
|
Assignment* matchingStaticAssignment = NULL;
|
||||||
|
|
||||||
if (memchr(STATICALLY_ASSIGNED_NODES, nodeType, sizeof(STATICALLY_ASSIGNED_NODES)) == NULL ||
|
if (memchr(STATICALLY_ASSIGNED_NODES, nodeType, sizeof(STATICALLY_ASSIGNED_NODES)) == NULL ||
|
||||||
(matchingStaticAssignment = matchingStaticAssignmentForCheckIn(nodeType, packetData))) {
|
((matchingStaticAssignment = matchingStaticAssignmentForCheckIn(nodeType, packetData)) ||
|
||||||
|
checkInWithUUIDMatchesExistingNode((sockaddr*) &nodePublicAddress,
|
||||||
|
(sockaddr*) &nodeLocalAddress,
|
||||||
|
packetData))) {
|
||||||
|
|
||||||
Node* checkInNode = nodeList->addOrUpdateNode((sockaddr*) &nodePublicAddress,
|
Node* checkInNode = nodeList->addOrUpdateNode((sockaddr*) &nodePublicAddress,
|
||||||
(sockaddr*) &nodeLocalAddress,
|
(sockaddr*) &nodeLocalAddress,
|
||||||
nodeType,
|
nodeType,
|
||||||
nodeList->getLastNodeID());
|
nodeList->getLastNodeID());
|
||||||
|
|
||||||
if (checkInNode->getNodeID() == nodeList->getLastNodeID() && matchingStaticAssignment) {
|
if (matchingStaticAssignment) {
|
||||||
// this was a newly added node
|
// this was a newly added node with a matching static assignment
|
||||||
NodeList::getInstance()->increaseNodeID();
|
|
||||||
|
|
||||||
if (_hasCompletedRestartHold) {
|
if (_hasCompletedRestartHold) {
|
||||||
// remove the matching assignment from the assignment queue so we don't take the next check in
|
// remove the matching assignment from the assignment queue so we don't take the next check in
|
||||||
|
@ -393,6 +418,7 @@ int DomainServer::run() {
|
||||||
// set the linked data for this node to a copy of the matching assignment
|
// set the linked data for this node to a copy of the matching assignment
|
||||||
// so we can re-queue it should the node die
|
// so we can re-queue it should the node die
|
||||||
Assignment* nodeCopyOfMatchingAssignment = new Assignment(*matchingStaticAssignment);
|
Assignment* nodeCopyOfMatchingAssignment = new Assignment(*matchingStaticAssignment);
|
||||||
|
|
||||||
checkInNode->setLinkedData(nodeCopyOfMatchingAssignment);
|
checkInNode->setLinkedData(nodeCopyOfMatchingAssignment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,7 @@ private:
|
||||||
Assignment* matchingStaticAssignmentForCheckIn(NODE_TYPE nodeType, const uchar* checkInUUID);
|
Assignment* matchingStaticAssignmentForCheckIn(NODE_TYPE nodeType, const uchar* checkInUUID);
|
||||||
Assignment* deployableAssignmentForRequest(Assignment& requestAssignment);
|
Assignment* deployableAssignmentForRequest(Assignment& requestAssignment);
|
||||||
void removeAssignmentFromQueue(Assignment* removableAssignment);
|
void removeAssignmentFromQueue(Assignment* removableAssignment);
|
||||||
|
bool checkInWithUUIDMatchesExistingNode(sockaddr* nodePublicSocket, sockaddr* nodeLocalSocket, const uchar* checkInData);
|
||||||
|
|
||||||
void cleanup();
|
void cleanup();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue