History

repair assignment flow errors from packet changes

Stephen Birarda committed 12 years ago

Commit 85ebad91 parent 3854f755 files · +54 −38Browse files

Showing the changes to assignment-client/src/AssignmentClient.cpp (1 of 5 files). Show all

Unified · Split

assignment-client/src/AssignmentClient.cpp+30−26
@@ -124,32 +124,36 @@ void AssignmentClient::readPendingDatagrams() { · 123 unmodified lines
124124 // construct the deployed assignment from the packet data
125125 _currentAssignment = AssignmentFactory::unpackAssignment(receivedPacket);
126126
127− qDebug() << "Received an assignment -" << *_currentAssignment;
128−
129− // switch our nodelist domain IP and port to whoever sent us the assignment
130−
131− nodeList->setDomainSockAddr(senderSockAddr);
132− nodeList->setOwnerUUID(_currentAssignment->getUUID());
133−
134− qDebug() << "Destination IP for assignment is" << nodeList->getDomainIP().toString();
135−
136− // start the deployed assignment
137− QThread* workerThread = new QThread(this);
138−
139− connect(workerThread, SIGNAL(started()), _currentAssignment, SLOT(run()));
140−
141− connect(_currentAssignment, SIGNAL(finished()), this, SLOT(assignmentCompleted()));
142− connect(_currentAssignment, SIGNAL(finished()), workerThread, SLOT(quit()));
143− connect(_currentAssignment, SIGNAL(finished()), _currentAssignment, SLOT(deleteLater()));
144− connect(workerThread, SIGNAL(finished()), workerThread, SLOT(deleteLater()));
145−
146− _currentAssignment->moveToThread(workerThread);
147−
148− // move the NodeList to the thread used for the _current assignment
149− nodeList->moveToThread(workerThread);
150−
151− // Starts an event loop, and emits workerThread->started()
152− workerThread->start();
127+ if (_currentAssignment) {
128+ qDebug() << "Received an assignment -" << *_currentAssignment;
129+
130+ // switch our nodelist domain IP and port to whoever sent us the assignment
131+
132+ nodeList->setDomainSockAddr(senderSockAddr);
133+ nodeList->setOwnerUUID(_currentAssignment->getUUID());
134+
135+ qDebug() << "Destination IP for assignment is" << nodeList->getDomainIP().toString();
136+
137+ // start the deployed assignment
138+ QThread* workerThread = new QThread(this);
139+
140+ connect(workerThread, SIGNAL(started()), _currentAssignment, SLOT(run()));
141+
142+ connect(_currentAssignment, SIGNAL(finished()), this, SLOT(assignmentCompleted()));
143+ connect(_currentAssignment, SIGNAL(finished()), workerThread, SLOT(quit()));
144+ connect(_currentAssignment, SIGNAL(finished()), _currentAssignment, SLOT(deleteLater()));
145+ connect(workerThread, SIGNAL(finished()), workerThread, SLOT(deleteLater()));
146+
147+ _currentAssignment->moveToThread(workerThread);
148+
149+ // move the NodeList to the thread used for the _current assignment
150+ nodeList->moveToThread(workerThread);
151+
152+ // Starts an event loop, and emits workerThread->started()
153+ workerThread->start();
154+ } else {
155+ qDebug() << "Received an assignment that could not be unpacked. Re-requesting.";
156+ }
153157 }
154158 } else {
155159 // have the NodeList attempt to handle it

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t