mirror of
https://github.com/JulianGro/overte.git
synced 2025-08-05 12:39:39 +02:00
Merge pull request #16250 from Atlante45/fix/account-settings
DEV-648: Limit the amount of account settings pull retries
This commit is contained in:
commit
d507c06a3b
2 changed files with 23 additions and 5 deletions
|
@ -48,7 +48,8 @@ Q_DECLARE_METATYPE(JSONCallbackParameters)
|
||||||
const QString ACCOUNTS_GROUP = "accounts";
|
const QString ACCOUNTS_GROUP = "accounts";
|
||||||
|
|
||||||
const int POST_SETTINGS_INTERVAL = 10 * MSECS_PER_SECOND;
|
const int POST_SETTINGS_INTERVAL = 10 * MSECS_PER_SECOND;
|
||||||
const int PULL_SETTINGS_RETRY_INTERVAL = 1 * MSECS_PER_SECOND;
|
const int PULL_SETTINGS_RETRY_INTERVAL = 2 * MSECS_PER_SECOND;
|
||||||
|
const int MAX_PULL_RETRIES = 10;
|
||||||
|
|
||||||
JSONCallbackParameters::JSONCallbackParameters(QObject* callbackReceiver,
|
JSONCallbackParameters::JSONCallbackParameters(QObject* callbackReceiver,
|
||||||
const QString& jsonCallbackMethod,
|
const QString& jsonCallbackMethod,
|
||||||
|
@ -93,9 +94,14 @@ AccountManager::AccountManager(bool accountSettingsEnabled, UserAgentGetter user
|
||||||
connect(this, &AccountManager::loginComplete, this, &AccountManager::uploadPublicKey);
|
connect(this, &AccountManager::loginComplete, this, &AccountManager::uploadPublicKey);
|
||||||
connect(this, &AccountManager::loginComplete, this, &AccountManager::requestAccountSettings);
|
connect(this, &AccountManager::loginComplete, this, &AccountManager::requestAccountSettings);
|
||||||
|
|
||||||
|
_pullSettingsRetryTimer = new QTimer(this);
|
||||||
|
_pullSettingsRetryTimer->setSingleShot(true);
|
||||||
|
_pullSettingsRetryTimer->setInterval(PULL_SETTINGS_RETRY_INTERVAL);
|
||||||
|
connect(_pullSettingsRetryTimer, &QTimer::timeout, this, &AccountManager::requestAccountSettings);
|
||||||
|
|
||||||
_postSettingsTimer = new QTimer(this);
|
_postSettingsTimer = new QTimer(this);
|
||||||
_postSettingsTimer->setInterval(POST_SETTINGS_INTERVAL);
|
_postSettingsTimer->setInterval(POST_SETTINGS_INTERVAL);
|
||||||
connect(this, SIGNAL(loginComplete(QUrl)), _postSettingsTimer, SLOT(start()));
|
connect(this, SIGNAL(accountSettingsLoaded()), _postSettingsTimer, SLOT(start()));
|
||||||
connect(this, &AccountManager::logoutComplete, _postSettingsTimer, &QTimer::stop);
|
connect(this, &AccountManager::logoutComplete, _postSettingsTimer, &QTimer::stop);
|
||||||
connect(_postSettingsTimer, &QTimer::timeout, this, &AccountManager::postAccountSettings);
|
connect(_postSettingsTimer, &QTimer::timeout, this, &AccountManager::postAccountSettings);
|
||||||
connect(qApp, &QCoreApplication::aboutToQuit, this, &AccountManager::postAccountSettings);
|
connect(qApp, &QCoreApplication::aboutToQuit, this, &AccountManager::postAccountSettings);
|
||||||
|
@ -105,6 +111,7 @@ const QString ACCOUNT_MANAGER_REQUESTED_SCOPE = "owner";
|
||||||
|
|
||||||
void AccountManager::logout() {
|
void AccountManager::logout() {
|
||||||
postAccountSettings();
|
postAccountSettings();
|
||||||
|
_numPullRetries = 0;
|
||||||
|
|
||||||
// a logout means we want to delete the DataServerAccountInfo we currently have for this URL, in-memory and in file
|
// a logout means we want to delete the DataServerAccountInfo we currently have for this URL, in-memory and in file
|
||||||
_accountInfo = DataServerAccountInfo();
|
_accountInfo = DataServerAccountInfo();
|
||||||
|
@ -831,17 +838,26 @@ void AccountManager::requestAccountSettingsFinished() {
|
||||||
emit accountSettingsLoaded();
|
emit accountSettingsLoaded();
|
||||||
} else {
|
} else {
|
||||||
qCDebug(networking) << "Error in response for account settings: no data object";
|
qCDebug(networking) << "Error in response for account settings: no data object";
|
||||||
QTimer::singleShot(PULL_SETTINGS_RETRY_INTERVAL, this, &AccountManager::requestAccountSettings);
|
if (!_pullSettingsRetryTimer->isActive() && _numPullRetries < MAX_PULL_RETRIES) {
|
||||||
|
++_numPullRetries;
|
||||||
|
_pullSettingsRetryTimer->start();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
qCDebug(networking) << "Error in response for account settings" << lockerReply->errorString();
|
qCDebug(networking) << "Error in response for account settings" << lockerReply->errorString();
|
||||||
QTimer::singleShot(PULL_SETTINGS_RETRY_INTERVAL, this, &AccountManager::requestAccountSettings);
|
if (!_pullSettingsRetryTimer->isActive() && _numPullRetries < MAX_PULL_RETRIES) {
|
||||||
|
++_numPullRetries;
|
||||||
|
_pullSettingsRetryTimer->start();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AccountManager::requestAccountSettingsError(QNetworkReply::NetworkError error) {
|
void AccountManager::requestAccountSettingsError(QNetworkReply::NetworkError error) {
|
||||||
qCWarning(networking) << "Account settings request encountered an error" << error;
|
qCWarning(networking) << "Account settings request encountered an error" << error;
|
||||||
QTimer::singleShot(PULL_SETTINGS_RETRY_INTERVAL, this, &AccountManager::requestAccountSettings);
|
if (!_pullSettingsRetryTimer->isActive() && _numPullRetries < MAX_PULL_RETRIES) {
|
||||||
|
++_numPullRetries;
|
||||||
|
_pullSettingsRetryTimer->start();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AccountManager::postAccountSettings() {
|
void AccountManager::postAccountSettings() {
|
||||||
|
|
|
@ -186,6 +186,8 @@ private:
|
||||||
AccountSettings _settings;
|
AccountSettings _settings;
|
||||||
quint64 _currentSyncTimestamp { 0 };
|
quint64 _currentSyncTimestamp { 0 };
|
||||||
quint64 _lastSuccessfulSyncTimestamp { 0 };
|
quint64 _lastSuccessfulSyncTimestamp { 0 };
|
||||||
|
int _numPullRetries { 0 };
|
||||||
|
QTimer* _pullSettingsRetryTimer { nullptr };
|
||||||
QTimer* _postSettingsTimer { nullptr };
|
QTimer* _postSettingsTimer { nullptr };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue