mirror of
https://github.com/overte-org/overte.git
synced 2025-04-08 08:14:48 +02:00
have AC making create request use its own UUID
This commit is contained in:
parent
3449ddc9a0
commit
fb27e37607
3 changed files with 38 additions and 10 deletions
|
@ -83,7 +83,7 @@ void DomainServer::nodeKilled(Node* node) {
|
|||
if (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
|
||||
for (int i = 0; i < MAX_STATIC_ASSIGNMENT_FILE_ASSIGNMENTS; i++) {
|
||||
|
@ -494,17 +494,41 @@ int DomainServer::run() {
|
|||
|
||||
qDebug() << "Received a create assignment -" << *createAssignment << "\n";
|
||||
|
||||
// add the assignment at the back of the queue
|
||||
_assignmentQueueMutex.lock();
|
||||
_assignmentQueue.push_back(createAssignment);
|
||||
_assignmentQueueMutex.unlock();
|
||||
// check the node public address
|
||||
// if it matches our local address
|
||||
// or if it's the loopback address we're on the same box
|
||||
if (nodePublicAddress.sin_addr.s_addr == serverLocalAddress ||
|
||||
nodePublicAddress.sin_addr.s_addr == htonl(INADDR_LOOPBACK)) {
|
||||
|
||||
nodePublicAddress.sin_addr.s_addr = 0;
|
||||
}
|
||||
|
||||
// find the first available spot in the static assignments and put this assignment there
|
||||
for (int i = 0; i < MAX_STATIC_ASSIGNMENT_FILE_ASSIGNMENTS; i++) {
|
||||
if (_staticAssignments[i].getUUID().isNull()) {
|
||||
_staticAssignments[i] = *createAssignment;
|
||||
// make sure we have a matching node with the UUID packed with the assignment
|
||||
// if the node has sent no types of interest, assume they want nothing but their own ID back
|
||||
for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
|
||||
if (node->getLinkedData()
|
||||
&& socketMatch((sockaddr*) &nodePublicAddress, node->getPublicSocket())
|
||||
&& ((Assignment*) node->getLinkedData())->getUUID() == createAssignment->getUUID()) {
|
||||
|
||||
// we've stuck the assignment in, break out
|
||||
// give the create assignment a new UUID
|
||||
createAssignment->resetUUID();
|
||||
|
||||
// add the assignment at the back of the queue
|
||||
_assignmentQueueMutex.lock();
|
||||
_assignmentQueue.push_back(createAssignment);
|
||||
_assignmentQueueMutex.unlock();
|
||||
|
||||
// find the first available spot in the static assignments and put this assignment there
|
||||
for (int i = 0; i < MAX_STATIC_ASSIGNMENT_FILE_ASSIGNMENTS; i++) {
|
||||
if (_staticAssignments[i].getUUID().isNull()) {
|
||||
_staticAssignments[i] = *createAssignment;
|
||||
|
||||
// we've stuck the assignment in, break out
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// we found the matching node that asked for create assignment, break out
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,6 +58,7 @@ public:
|
|||
/// \param numBytes the number of bytes left to read in the source buffer
|
||||
Assignment(const unsigned char* dataBuffer, int numBytes);
|
||||
|
||||
void setUUID(const QUuid& uuid) { _uuid = uuid; }
|
||||
const QUuid& getUUID() const { return _uuid; }
|
||||
QString getUUIDStringWithoutCurlyBraces() const;
|
||||
void resetUUID() { _uuid = QUuid::createUuid(); }
|
||||
|
|
|
@ -160,6 +160,9 @@ void VoxelServer::parseOtherServerConfigs() {
|
|||
Assignment::VoxelServerType,
|
||||
getLocation()); // use same location as we were created in.
|
||||
|
||||
// match this create request with our UUID so the DS knows who the create request is from
|
||||
voxelServerAssignment.setUUID(_uuid);
|
||||
|
||||
int payloadLength = config.length() + sizeof(char);
|
||||
voxelServerAssignment.setPayload((uchar*)config.toLocal8Bit().constData(), payloadLength);
|
||||
|
||||
|
|
Loading…
Reference in a new issue