mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 09:48:44 +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();
|
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() {
|
void AssignmentClientMonitor::stopChildProcesses() {
|
||||||
auto nodeList = DependencyManager::get<NodeList>();
|
auto nodeList = DependencyManager::get<NodeList>();
|
||||||
|
|
||||||
|
@ -78,8 +89,10 @@ void AssignmentClientMonitor::stopChildProcesses() {
|
||||||
QByteArray diePacket = byteArrayWithPopulatedHeader(PacketTypeStopNode);
|
QByteArray diePacket = byteArrayWithPopulatedHeader(PacketTypeStopNode);
|
||||||
nodeList->writeUnverifiedDatagram(diePacket, *node->getActiveSocket());
|
nodeList->writeUnverifiedDatagram(diePacket, *node->getActiveSocket());
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
|
// try to give all the children time to shutdown
|
||||||
|
waitOnChildren(15000);
|
||||||
|
}
|
||||||
|
|
||||||
void AssignmentClientMonitor::aboutToQuit() {
|
void AssignmentClientMonitor::aboutToQuit() {
|
||||||
stopChildProcesses();
|
stopChildProcesses();
|
||||||
|
@ -87,10 +100,11 @@ void AssignmentClientMonitor::aboutToQuit() {
|
||||||
qInstallMessageHandler(0);
|
qInstallMessageHandler(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AssignmentClientMonitor::spawnChildClient() {
|
void AssignmentClientMonitor::spawnChildClient() {
|
||||||
QProcess *assignmentClient = new QProcess(this);
|
QProcess *assignmentClient = new QProcess(this);
|
||||||
|
|
||||||
|
_childProcesses.append(assignmentClient);
|
||||||
|
|
||||||
// unparse the parts of the command-line that the child cares about
|
// unparse the parts of the command-line that the child cares about
|
||||||
QStringList _childArguments;
|
QStringList _childArguments;
|
||||||
if (_assignmentPool != "") {
|
if (_assignmentPool != "") {
|
||||||
|
@ -127,8 +141,6 @@ void AssignmentClientMonitor::spawnChildClient() {
|
||||||
qDebug() << "Spawned a child client with PID" << assignmentClient->pid();
|
qDebug() << "Spawned a child client with PID" << assignmentClient->pid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void AssignmentClientMonitor::checkSpares() {
|
void AssignmentClientMonitor::checkSpares() {
|
||||||
auto nodeList = DependencyManager::get<NodeList>();
|
auto nodeList = DependencyManager::get<NodeList>();
|
||||||
QUuid aSpareId = "";
|
QUuid aSpareId = "";
|
||||||
|
@ -164,6 +176,8 @@ void AssignmentClientMonitor::checkSpares() {
|
||||||
nodeList->writeUnverifiedDatagram(diePacket, childNode);
|
nodeList->writeUnverifiedDatagram(diePacket, childNode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
waitOnChildren(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,8 @@ public:
|
||||||
QString assignmentPool, QUuid walletUUID, QString assignmentServerHostname,
|
QString assignmentPool, QUuid walletUUID, QString assignmentServerHostname,
|
||||||
quint16 assignmentServerPort);
|
quint16 assignmentServerPort);
|
||||||
~AssignmentClientMonitor();
|
~AssignmentClientMonitor();
|
||||||
|
|
||||||
|
void waitOnChildren(int msecs);
|
||||||
void stopChildProcesses();
|
void stopChildProcesses();
|
||||||
private slots:
|
private slots:
|
||||||
void readPendingDatagrams();
|
void readPendingDatagrams();
|
||||||
|
@ -55,6 +56,7 @@ private:
|
||||||
QString _assignmentServerHostname;
|
QString _assignmentServerHostname;
|
||||||
quint16 _assignmentServerPort;
|
quint16 _assignmentServerPort;
|
||||||
|
|
||||||
|
QList<QProcess*> _childProcesses;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_AssignmentClientMonitor_h
|
#endif // hifi_AssignmentClientMonitor_h
|
||||||
|
|
|
@ -27,8 +27,6 @@ EntityServer::EntityServer(const QByteArray& packet)
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityServer::~EntityServer() {
|
EntityServer::~EntityServer() {
|
||||||
qDebug() << "EntityServer::~EntityServer";
|
|
||||||
|
|
||||||
if (_pruneDeletedEntitiesTimer) {
|
if (_pruneDeletedEntitiesTimer) {
|
||||||
_pruneDeletedEntitiesTimer->stop();
|
_pruneDeletedEntitiesTimer->stop();
|
||||||
_pruneDeletedEntitiesTimer->deleteLater();
|
_pruneDeletedEntitiesTimer->deleteLater();
|
||||||
|
|
Loading…
Reference in a new issue