From 052028afe8bbc905de40666976c75d7c5e0296b6 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Thu, 29 Feb 2024 11:30:24 +0100 Subject: [PATCH] Check if download/reporting thread are running --- update.cpp | 42 +++++++++++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/update.cpp b/update.cpp index 6f95e32..944b3a4 100644 --- a/update.cpp +++ b/update.cpp @@ -655,9 +655,14 @@ bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) { QThread::sleep(2); - if (!m_hw->dcDownloadRunning()) { // may take some time - qCritical() << QDateTime::currentDateTime().toString(Qt::ISODate) - << "(" << __func__ << ":" << __LINE__ << ") DOWNLOAD NOT RUNNING"; + int tries = 5; + while (!m_hw->dcDownloadRunning()) { // may take some time + if (--tries < 0) { + qCritical() << QDateTime::currentDateTime().toString(Qt::ISODate) + << "(" << __func__ << ":" << __LINE__ << ") DOWNLOAD NOT RUNNING"; + break; + } + QThread::sleep(1); continue; } @@ -666,9 +671,13 @@ bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) { QThread::sleep(2); - if (!m_hw->dcDownloadReportThreadStart()) { // may take some time - qCritical() << QDateTime::currentDateTime().toString(Qt::ISODate) - << "(" << __func__ << ":" << __LINE__ << ") REPORT THREAD NOT STARTED"; + tries = 5; + while (!m_hw->dcDownloadReportThreadStart()) { // may take some time + if (--tries < 0) { + qCritical() << QDateTime::currentDateTime().toString(Qt::ISODate) + << "(" << __func__ << ":" << __LINE__ << ") REPORT THREAD NOT STARTED"; + break; + } continue; } @@ -676,18 +685,29 @@ bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) { << "(" << __func__ << ":" << __LINE__ << ") REPORT THREAD STARTED"; QThread::sleep(2); - if (!m_hw->dcDownloadReportRunning()) { // may take some time - qCritical() << QDateTime::currentDateTime().toString(Qt::ISODate) - << "(" << __func__ << ":" << __LINE__ << ") DOWNLOAD REPORT NOT RUNNING"; + + tries = 5; + while (!m_hw->dcDownloadReportRunning()) { // may take some time + if (--tries < 0) { + qCritical() << QDateTime::currentDateTime().toString(Qt::ISODate) + << "(" << __func__ << ":" << __LINE__ << ") DOWNLOAD REPORT NOT RUNNING"; + break; + } continue; } qCritical() << QDateTime::currentDateTime().toString(Qt::ISODate) << "(" << __func__ << ":" << __LINE__ << ") DOWNLOAD REPORT RUNNING"; - + tries = 1200; while (m_hw->dcDownloadReportRunning()) { - QThread::msleep(500); + QThread::msleep(1000); + if (--tries < 0) { + qCritical() << QDateTime::currentDateTime().toString(Qt::ISODate) + << "(" << __func__ << ":" << __LINE__ + << ") DOWNLOAD REPORT STILL RUNNING AFTER 20mins"; + break; + } } bool updateBinaryRes = true;