Ref T400, swift needs to start even without network connection, especially for mapping tool

* count errors and call "manageSetupAvailability" to update cache availability
* minor adjustments
This commit is contained in:
Klaus Basan
2018-10-22 18:39:37 +02:00
parent 21bc1f7dbe
commit 4a82621a1d
4 changed files with 19 additions and 8 deletions

View File

@@ -415,6 +415,8 @@ namespace BlackCore
// setup handling completed with success or failure, or we run into time out
if (m_setupReader->isSetupAvailable()) { return CStatusMessage(this).info("Setup available"); }
// getting here can means no "real" read success, and NO available cache
CStatusMessageList msgs(CStatusMessage(this).error("Setup not available, setup reading failed or timed out."));
if (m_setupReader->getLastSetupReadErrorMessages().hasErrorMessages())
{

View File

@@ -80,7 +80,7 @@ namespace BlackCore
msgs.push_back(cacheAvailable ?
CStatusMessage(this, CStatusMessage::SeverityInfo, "Cache only setup, using it as it is") :
CStatusMessage(this, CStatusMessage::SeverityError, "Cache only setup, but cache is empty"));
msgs.push_back(this->manageSetupAvailability(false, false));
msgs.push_back(this->manageSetupAvailability(false, false)); // treat cache as local read
return msgs;
}
@@ -382,7 +382,6 @@ namespace BlackCore
if (setupJson.isEmpty())
{
CLogMessage(this).info("No bootstrap setup file at '%1'") << urlString;
// try next URL
}
else
{
@@ -431,9 +430,9 @@ namespace BlackCore
const CStatusMessage msg = ex.toStatusMessage(this, errorMsg);
CLogMessage::preformatted(msg);
// in dev. I get notified, in productive code I try next URL
// by falling thru
// in dev. I get notified, in productive code I try next URL by falling thru
BLACK_VERIFY_X(false, Q_FUNC_INFO, errorMsg.toLocal8Bit().constData());
m_bootstrapReadErrors++;
}
} // json empty
} // no error
@@ -442,6 +441,12 @@ namespace BlackCore
// network error, log as warning as we will read again if possible
// however, store as error because this will be a possible root cause if nothing else is
nwReply->abort();
m_bootstrapReadErrors++;
if (m_bootstrapReadErrors > 1)
{
// getting here means at least 2 URLs failes
this->manageSetupAvailability(false); // this updates also the cache availability so we can contine with cache only
}
}
}
@@ -508,6 +513,7 @@ namespace BlackCore
// in dev. I get notified, in productive code I try next URL by falling thru
BLACK_VERIFY_X(false, Q_FUNC_INFO, errorMsg.toLocal8Bit().constData());
m_updateInfoReadErrors++;
}
} // json empty
} // no error
@@ -515,6 +521,7 @@ namespace BlackCore
{
// network error, try next URL
nwReply->abort();
m_updateInfoReadErrors++;
}
}

View File

@@ -120,10 +120,10 @@ namespace BlackCore
QString getBootstrapModeAsString() const;
signals:
//! Setup fetched or failed (from web, cache, or local file)
//! Setup fetched or failed (from web, cache, or local file)?
void setupHandlingCompleted(bool available);
//! Update infao available (from web, cache)
//! Update info available (from web, cache)?
void updateInfoAvailable(bool available);
//! A shared URL was successfully read
@@ -164,9 +164,11 @@ namespace BlackCore
std::atomic<bool> m_shutdown { false };
std::atomic<bool> m_setupAvailable { false }; //!< setup available
std::atomic<bool> m_updateInfoAvailable { false }; //!< update info available
std::atomic<bool> m_updateInfoAvailable { false }; //!< update info available
std::atomic<bool> m_ignoreCmdBootstrapUrl { false }; //!< ignore the explicitly set bootstrap URL
std::atomic<bool> m_checkCmdBootstrapUrl { true }; //!< check connection on CMD bootstrap URL
std::atomic_int m_bootstrapReadErrors { 0 }; //!< failed bootstrap reads
std::atomic_int m_updateInfoReadErrors { 0 }; //!< failed version info reads
QString m_localSetupFileValue; //!< Local file for setup, passed by cmd line arguments
QString m_bootstrapUrlFileValue; //!< Bootstrap URL if not local
BootstrapMode m_bootstrapMode = Explicit; //!< How to bootstrap