mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 03:44:02 +02:00
AssignmentClientMonitor now waits() on children
This commit is contained in:
parent
69766f6e59
commit
b041fd1b7f
3 changed files with 21 additions and 7 deletions
|
@ -69,6 +69,17 @@ AssignmentClientMonitor::~AssignmentClientMonitor() {
|
|||
stopChildProcesses();
|
||||
}
|
||||
|
||||
void AssignmentClientMonitor::waitOnChildren(int msecs) {
|
||||
QMutableListIterator<QProcess*> i(_childProcesses);
|
||||
while (i.hasNext()) {
|
||||
QProcess* childProcess = i.next();
|
||||
bool finished = childProcess->waitForFinished(msecs);
|
||||
if (finished) {
|
||||
i.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AssignmentClientMonitor::stopChildProcesses() {
|
||||
auto nodeList = DependencyManager::get<NodeList>();
|
||||
|
||||
|
@ -78,8 +89,10 @@ void AssignmentClientMonitor::stopChildProcesses() {
|
|||
QByteArray diePacket = byteArrayWithPopulatedHeader(PacketTypeStopNode);
|
||||
nodeList->writeUnverifiedDatagram(diePacket, *node->getActiveSocket());
|
||||
});
|
||||
}
|
||||
|
||||
// try to give all the children time to shutdown
|
||||
waitOnChildren(15000);
|
||||
}
|
||||
|
||||
void AssignmentClientMonitor::aboutToQuit() {
|
||||
stopChildProcesses();
|
||||
|
@ -87,10 +100,11 @@ void AssignmentClientMonitor::aboutToQuit() {
|
|||
qInstallMessageHandler(0);
|
||||
}
|
||||
|
||||
|
||||
void AssignmentClientMonitor::spawnChildClient() {
|
||||
QProcess *assignmentClient = new QProcess(this);
|
||||
|
||||
_childProcesses.append(assignmentClient);
|
||||
|
||||
// unparse the parts of the command-line that the child cares about
|
||||
QStringList _childArguments;
|
||||
if (_assignmentPool != "") {
|
||||
|
@ -127,8 +141,6 @@ void AssignmentClientMonitor::spawnChildClient() {
|
|||
qDebug() << "Spawned a child client with PID" << assignmentClient->pid();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AssignmentClientMonitor::checkSpares() {
|
||||
auto nodeList = DependencyManager::get<NodeList>();
|
||||
QUuid aSpareId = "";
|
||||
|
@ -164,6 +176,8 @@ void AssignmentClientMonitor::checkSpares() {
|
|||
nodeList->writeUnverifiedDatagram(diePacket, childNode);
|
||||
}
|
||||
}
|
||||
|
||||
waitOnChildren(0);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -32,7 +32,8 @@ public:
|
|||
QString assignmentPool, QUuid walletUUID, QString assignmentServerHostname,
|
||||
quint16 assignmentServerPort);
|
||||
~AssignmentClientMonitor();
|
||||
|
||||
|
||||
void waitOnChildren(int msecs);
|
||||
void stopChildProcesses();
|
||||
private slots:
|
||||
void readPendingDatagrams();
|
||||
|
@ -55,6 +56,7 @@ private:
|
|||
QString _assignmentServerHostname;
|
||||
quint16 _assignmentServerPort;
|
||||
|
||||
QList<QProcess*> _childProcesses;
|
||||
};
|
||||
|
||||
#endif // hifi_AssignmentClientMonitor_h
|
||||
|
|
|
@ -27,8 +27,6 @@ EntityServer::EntityServer(const QByteArray& packet)
|
|||
}
|
||||
|
||||
EntityServer::~EntityServer() {
|
||||
qDebug() << "EntityServer::~EntityServer";
|
||||
|
||||
if (_pruneDeletedEntitiesTimer) {
|
||||
_pruneDeletedEntitiesTimer->stop();
|
||||
_pruneDeletedEntitiesTimer->deleteLater();
|
||||
|
|
Loading…
Reference in a new issue