mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 14:55:36 +08:00
Make datastore ping interval configurable
And don't bother sending pings more frequently if the server is struggling to reply to every one.
This commit is contained in:
@@ -38,6 +38,7 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"pingIntervalSecs": 180,
|
||||
"predefinedServers": {
|
||||
"containerbase": [
|
||||
]
|
||||
|
||||
@@ -150,6 +150,9 @@ namespace BlackCore
|
||||
//! Ping the DB server, fire and forget (no feedback etc)
|
||||
BlackMisc::Network::CUrl getDbClientPingServiceUrl(PingType type) const;
|
||||
|
||||
//! Seconds between pings
|
||||
qint64 getDbClientPingIntervalSecs() const { return m_pingIntervalSecs; }
|
||||
|
||||
//! alpha XSwiftBus files available
|
||||
BlackMisc::Network::CUrl getAlphaXSwiftBusFilesServiceUrl() const;
|
||||
|
||||
@@ -245,6 +248,7 @@ namespace BlackCore
|
||||
bool m_wasLoadedFromFile = false; //!< Loaded from local file
|
||||
int m_dbHttpPort = 80; //!< port
|
||||
int m_dbHttpsPort = 443; //!< SSL port
|
||||
qint64 m_pingIntervalSecs = 180; //!< seconds between datastore pings
|
||||
bool m_development = false; //!< dev. version?
|
||||
QString m_mappingMinimumVersion; //!< minimum version
|
||||
BlackMisc::Network::CUrl m_crashReportServerUrl; //!< crash report server
|
||||
@@ -276,6 +280,7 @@ namespace BlackCore
|
||||
BLACK_METAMEMBER(dbRootDirectoryUrl),
|
||||
BLACK_METAMEMBER(dbHttpPort),
|
||||
BLACK_METAMEMBER(dbHttpsPort),
|
||||
BLACK_METAMEMBER(pingIntervalSecs),
|
||||
BLACK_METAMEMBER(vatsimStatusFileUrls),
|
||||
BLACK_METAMEMBER(vatsimDataFileUrls),
|
||||
BLACK_METAMEMBER(vatsimBookingsUrl),
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "blackmisc/network/networkutils.h"
|
||||
|
||||
#include <QNetworkReply>
|
||||
#include <QDateTime>
|
||||
#include <QPointer>
|
||||
|
||||
using namespace BlackMisc;
|
||||
@@ -146,19 +147,13 @@ namespace BlackCore
|
||||
|
||||
if (m_checkDbAccessibility && m_doDetailedCheck && canConnectDb)
|
||||
{
|
||||
// test against real HTTP response
|
||||
const bool lastHttpSuccess = m_lastClientPingSuccess; // ping result received in meantime
|
||||
if (lastHttpSuccess && m_totalCheckCount % 10 == 0)
|
||||
const qint64 pingIntervalSecs = sApp->getGlobalSetup().getDbClientPingIntervalSecs();
|
||||
if (QDateTime::currentSecsSinceEpoch() >= pingIntervalSecs)
|
||||
{
|
||||
// seems to be OK, from time to time ping
|
||||
m_nextPingSecsSinceEpoch = QDateTime::currentSecsSinceEpoch() + pingIntervalSecs;
|
||||
this->pingDbClientService(CGlobalSetup::PingStarted);
|
||||
canConnectDb = m_lastClientPingSuccess;
|
||||
}
|
||||
else if (!lastHttpSuccess && m_totalCheckCount % 3 == 0)
|
||||
{
|
||||
// not OK, retry more frequently
|
||||
this->pingDbClientService(CGlobalSetup::PingStarted, true); // force
|
||||
}
|
||||
canConnectDb = lastHttpSuccess;
|
||||
}
|
||||
|
||||
bool canConnectInternet = canConnectDb;
|
||||
|
||||
@@ -190,6 +190,7 @@ namespace BlackCore
|
||||
std::atomic_bool m_checkDbAccessibility { true };
|
||||
std::atomic_bool m_checkSharedUrl { true };
|
||||
std::atomic_bool m_checkInProgress { false }; //!< a check is currently in progress
|
||||
std::atomic<qint64> m_nextPingSecsSinceEpoch { 0 }; //!< time at which next ping will be sent
|
||||
std::atomic_int m_networkAccessibility { QNetworkAccessManager::Accessible }; //!< last state
|
||||
std::atomic_int m_totalCheckCount { 0 }; //!< counting number of checks
|
||||
std::atomic_int m_totalBadCountDb { 0 }; //!< Total number of DB failing counts (only real responses when tried)
|
||||
|
||||
Reference in New Issue
Block a user