mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 20:48:56 +02:00
Merge pull request #1156 from birarda/assignment
fix scripted assignment delete before it is sent out
This commit is contained in:
commit
c70d0c3d88
1 changed files with 12 additions and 8 deletions
|
@ -457,14 +457,13 @@ Assignment* DomainServer::deployableAssignmentForRequest(Assignment& requestAssi
|
|||
Assignment* deployableAssignment = *assignment;
|
||||
|
||||
if ((*assignment)->getType() == Assignment::AgentType) {
|
||||
// if this is a script assignment we need to delete it to avoid a memory leak
|
||||
// or if there is more than one instance to send out, simpy decrease the number of instances
|
||||
if ((*assignment)->getNumberOfInstances() > 1) {
|
||||
(*assignment)->decrementNumberOfInstances();
|
||||
} else {
|
||||
// if there is more than one instance to send out, simply decrease the number of instances
|
||||
|
||||
if ((*assignment)->getNumberOfInstances() == 1) {
|
||||
_assignmentQueue.erase(assignment);
|
||||
delete *assignment;
|
||||
}
|
||||
|
||||
(*assignment)->decrementNumberOfInstances();
|
||||
} else {
|
||||
// remove the assignment from the queue
|
||||
_assignmentQueue.erase(assignment);
|
||||
|
@ -735,6 +734,11 @@ int DomainServer::run() {
|
|||
nodeList->getNodeSocket()->send((sockaddr*) &senderAddress,
|
||||
broadcastPacket,
|
||||
numHeaderBytes + numAssignmentBytes);
|
||||
|
||||
if (assignmentToDeploy->getNumberOfInstances() == 0) {
|
||||
// there are no more instances of this script to send out, delete it
|
||||
delete assignmentToDeploy;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue