mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 14:55:36 +08:00
Do not trigger loads if they are doomed to fail
This commit is contained in:
@@ -35,6 +35,7 @@
|
||||
#include "blackmisc/stringutils.h"
|
||||
#include "blackmisc/threadutils.h"
|
||||
#include "blackmisc/verify.h"
|
||||
#include "application.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
@@ -720,6 +721,12 @@ namespace BlackCore
|
||||
return m_networkWatchDog && m_networkWatchDog->isSwiftDbAccessible();
|
||||
}
|
||||
|
||||
bool CApplication::hasWorkingSharedUrl() const
|
||||
{
|
||||
if (!this->isNetworkAccessible()) { return false; }
|
||||
return m_networkWatchDog && m_networkWatchDog->hasWorkingSharedUrl();
|
||||
}
|
||||
|
||||
CUrl CApplication::getWorkingSharedUrl() const
|
||||
{
|
||||
if (!m_networkWatchDog || !this->isNetworkAccessible()) { return CUrl(); }
|
||||
|
||||
@@ -178,6 +178,9 @@ namespace BlackCore
|
||||
//! \copydoc BlackCore::Db::CNetworkWatchdog::isSwiftDbAccessible
|
||||
bool isSwiftDbAccessible() const;
|
||||
|
||||
//! \copydoc BlackCore::Db::CNetworkWatchdog::hasWorkingSharedUrl
|
||||
bool hasWorkingSharedUrl() const;
|
||||
|
||||
//! \copydoc BlackCore::Db::CNetworkWatchdog::getWorkingSharedUrl
|
||||
BlackMisc::Network::CUrl getWorkingSharedUrl() const;
|
||||
|
||||
|
||||
@@ -45,16 +45,22 @@ namespace BlackCore
|
||||
QTimer::singleShot(0, &m_updateTimer, [this] { this->m_updateTimer.start(); }); // restart
|
||||
}
|
||||
|
||||
bool CNetworkWatchdog::hasWorkingSharedUrl() const
|
||||
{
|
||||
if (!m_networkAccessible) { return false; }
|
||||
return !this->getWorkingSharedUrl().isEmpty();
|
||||
}
|
||||
|
||||
CUrl CNetworkWatchdog::getWorkingSharedUrl() const
|
||||
{
|
||||
if (!m_networkAccessible) return CUrl();
|
||||
if (!m_networkAccessible) { return CUrl(); }
|
||||
QReadLocker l(&m_lockSharedUrl);
|
||||
return m_workingSharedUrl;
|
||||
}
|
||||
|
||||
int CNetworkWatchdog::triggerCheck()
|
||||
{
|
||||
if (!this->doWorkCheck()) return false; // senseless
|
||||
if (!this->doWorkCheck()) { return false; } // senseless
|
||||
if (m_checkInProgress) { return -1; }
|
||||
|
||||
const int n = this->getCheckCount();
|
||||
|
||||
@@ -62,6 +62,10 @@ namespace BlackCore
|
||||
//! \threadsafe
|
||||
bool isInternetAccessible() const { return m_internetAccessible; }
|
||||
|
||||
//! Has working shared URL?
|
||||
//! \threadsafe
|
||||
bool hasWorkingSharedUrl() const;
|
||||
|
||||
//! A working shared URL
|
||||
//! \threadsafe
|
||||
BlackMisc::Network::CUrl getWorkingSharedUrl() const;
|
||||
|
||||
@@ -269,6 +269,13 @@ namespace BlackCore
|
||||
CEntityFlags::Entity CWebDataServices::triggerLoadingDirectlyFromDb(CEntityFlags::Entity whatToRead, const QDateTime &newerThan)
|
||||
{
|
||||
if (m_shuttingDown) { return CEntityFlags::NoEntity; }
|
||||
if (!sApp || sApp->isShuttingDown()) { return CEntityFlags::NoEntity; }
|
||||
if (!sApp->isSwiftDbAccessible())
|
||||
{
|
||||
CLogMessage(this).warning("Not triggering load of '%1' because swift DB is not accessible") << CEntityFlags::flagToString(whatToRead);
|
||||
return CEntityFlags::NoEntity;
|
||||
}
|
||||
|
||||
CEntityFlags::Entity triggeredRead = CEntityFlags::NoEntity;
|
||||
if (m_dbInfoDataReader)
|
||||
{
|
||||
@@ -312,6 +319,13 @@ namespace BlackCore
|
||||
CEntityFlags::Entity CWebDataServices::triggerLoadingDirectlyFromSharedFiles(CEntityFlags::Entity whatToRead, bool checkCacheTsUpfront)
|
||||
{
|
||||
if (m_shuttingDown) { return CEntityFlags::NoEntity; }
|
||||
if (!sApp || sApp->isShuttingDown()) { return CEntityFlags::NoEntity; }
|
||||
if (!sApp->hasWorkingSharedUrl())
|
||||
{
|
||||
CLogMessage(this).warning("Not triggering load of '%1' because no working shared URL") << CEntityFlags::flagToString(whatToRead);
|
||||
return CEntityFlags::NoEntity;
|
||||
}
|
||||
|
||||
CEntityFlags::Entity triggeredRead = CEntityFlags::NoEntity;
|
||||
this->triggerReadOfSharedInfoObjects(); // trigger reload of info objects (for shared)
|
||||
|
||||
|
||||
@@ -523,7 +523,7 @@ namespace BlackCore
|
||||
BlackMisc::Network::CEntityFlags::Entity m_swiftDbEntitiesRead = BlackMisc::Network::CEntityFlags::NoEntity; //!< entities read
|
||||
BlackCore::Db::CDatabaseReaderConfigList m_dbReaderConfig; //!< how to read DB data
|
||||
bool m_initialRead = false; //!< initial read started
|
||||
bool m_signalledHeaders = false; //!< haders loading has been signalled
|
||||
bool m_signalledHeaders = false; //!< headers loading has been signalled
|
||||
bool m_shuttingDown = false; //!< shutting down?
|
||||
QDateTime m_dbInfoObjectTimeout; //!< started reading DB info objects
|
||||
QDateTime m_sharedInfoObjectsTimeout; //!< started reading shared info objects
|
||||
|
||||
Reference in New Issue
Block a user