Fix process finished crash if the http reply timed out in the mean time
This commit is contained in:
parent
28d2f53261
commit
432130b0af
@ -385,6 +385,9 @@ HttpReply *DebugServerHandler::processDebugRequest(const QString &requestPath, c
|
||||
m_pingProcess->start("ping", { "-c", "4", "nymea.io" } );
|
||||
|
||||
m_pingReply = HttpReply::createAsyncReply();
|
||||
connect(m_pingReply, &HttpReply::finished, this, [this](){
|
||||
m_pingReply = nullptr;
|
||||
});
|
||||
return m_pingReply;
|
||||
}
|
||||
|
||||
@ -400,6 +403,9 @@ HttpReply *DebugServerHandler::processDebugRequest(const QString &requestPath, c
|
||||
m_digProcess->start("dig", { "nymea.io" } );
|
||||
|
||||
m_digReply = HttpReply::createAsyncReply();
|
||||
connect(m_digReply, &HttpReply::finished, this, [this](){
|
||||
m_digReply = nullptr;
|
||||
});
|
||||
return m_digReply;
|
||||
}
|
||||
|
||||
@ -415,6 +421,9 @@ HttpReply *DebugServerHandler::processDebugRequest(const QString &requestPath, c
|
||||
m_tracePathProcess->start("tracepath", { "nymea.io" } );
|
||||
|
||||
m_tracePathReply = HttpReply::createAsyncReply();
|
||||
connect(m_tracePathReply, &HttpReply::finished, this, [this](){
|
||||
m_tracePathProcess = nullptr;
|
||||
});
|
||||
return m_tracePathReply;
|
||||
}
|
||||
|
||||
@ -687,46 +696,59 @@ void DebugServerHandler::onWebsocketClientError(QAbstractSocket::SocketError err
|
||||
void DebugServerHandler::onPingProcessFinished(int exitCode, QProcess::ExitStatus exitStatus)
|
||||
{
|
||||
qCDebug(dcDebugServer()) << "Ping process finished" << exitCode << exitStatus;
|
||||
QByteArray processOutput = m_pingProcess->readAll();
|
||||
qCDebug(dcDebugServer()) << "Ping output:" << endl << qUtf8Printable(processOutput);
|
||||
if (m_pingProcess) {
|
||||
QByteArray processOutput = m_pingProcess->readAll();
|
||||
qCDebug(dcDebugServer()) << "Ping output:" << endl << qUtf8Printable(processOutput);
|
||||
|
||||
m_pingReply->setPayload(processOutput);
|
||||
m_pingReply->setHttpStatusCode(HttpReply::Ok);
|
||||
m_pingReply->finished();
|
||||
m_pingReply = nullptr;
|
||||
if (m_pingReply) {
|
||||
m_pingReply->setPayload(processOutput);
|
||||
m_pingReply->setHttpStatusCode(HttpReply::Ok);
|
||||
m_pingReply->finished();
|
||||
m_pingReply = nullptr;
|
||||
}
|
||||
|
||||
m_pingProcess->deleteLater();
|
||||
m_pingProcess = nullptr;
|
||||
m_pingProcess->deleteLater();
|
||||
m_pingProcess = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void DebugServerHandler::onDigProcessFinished(int exitCode, QProcess::ExitStatus exitStatus)
|
||||
{
|
||||
qCDebug(dcDebugServer()) << "Dig process finished" << exitCode << exitStatus;
|
||||
QByteArray processOutput = m_digProcess->readAll();
|
||||
qCDebug(dcDebugServer()) << "Dig output:" << endl << qUtf8Printable(processOutput);
|
||||
if (m_digProcess) {
|
||||
QByteArray processOutput = m_digProcess->readAll();
|
||||
qCDebug(dcDebugServer()) << "Dig output:" << endl << qUtf8Printable(processOutput);
|
||||
|
||||
m_digReply->setPayload(processOutput);
|
||||
m_digReply->setHttpStatusCode(HttpReply::Ok);
|
||||
m_digReply->finished();
|
||||
m_digReply = nullptr;
|
||||
if (m_digReply) {
|
||||
m_digReply->setPayload(processOutput);
|
||||
m_digReply->setHttpStatusCode(HttpReply::Ok);
|
||||
m_digReply->finished();
|
||||
m_digReply = nullptr;
|
||||
}
|
||||
|
||||
m_digProcess->deleteLater();
|
||||
m_digProcess = nullptr;
|
||||
m_digProcess->deleteLater();
|
||||
m_digProcess = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void DebugServerHandler::onTracePathProcessFinished(int exitCode, QProcess::ExitStatus exitStatus)
|
||||
{
|
||||
qCDebug(dcDebugServer()) << "Tracepath process finished" << exitCode << exitStatus;
|
||||
QByteArray processOutput = m_tracePathProcess->readAll();
|
||||
qCDebug(dcDebugServer()) << "Tracepath output:" << endl << qUtf8Printable(processOutput);
|
||||
|
||||
m_tracePathReply->setPayload(processOutput);
|
||||
m_tracePathReply->setHttpStatusCode(HttpReply::Ok);
|
||||
m_tracePathReply->finished();
|
||||
m_tracePathReply = nullptr;
|
||||
if (m_tracePathProcess) {
|
||||
QByteArray processOutput = m_tracePathProcess->readAll();
|
||||
qCDebug(dcDebugServer()) << "Tracepath output:" << endl << qUtf8Printable(processOutput);
|
||||
|
||||
m_tracePathProcess->deleteLater();
|
||||
m_tracePathProcess = nullptr;
|
||||
if (m_tracePathReply) {
|
||||
m_tracePathReply->setPayload(processOutput);
|
||||
m_tracePathReply->setHttpStatusCode(HttpReply::Ok);
|
||||
m_tracePathReply->finished();
|
||||
m_tracePathReply = nullptr;
|
||||
}
|
||||
|
||||
m_tracePathProcess->deleteLater();
|
||||
m_tracePathProcess = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void DebugServerHandler::onDebugReportGeneratorFinished(bool success)
|
||||
|
||||
Reference in New Issue
Block a user