Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/owncloud/client.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Kamm <kamm@incasoftware.de>2014-10-24 12:57:16 +0400
committerChristian Kamm <kamm@incasoftware.de>2014-10-24 15:31:48 +0400
commit82b14370fc35e689f9b0bb7a61323831693bf6be (patch)
treede8ed7e49174ba9bfecd175ecc7383f07791d1f2 /src/mirall
parentf5c199740d6d792d32e476f772cfbea2394fdfa3 (diff)
Sync scheduling: Only retry up to twice after fail. #2386
Previously when a sync failed, we'd retry very soon (30s) no matter how often a sync had failed before. After this change we'll retry twice and then back off to the regular 5min interval.
Diffstat (limited to 'src/mirall')
-rw-r--r--src/mirall/folder.cpp25
-rw-r--r--src/mirall/folder.h1
2 files changed, 20 insertions, 6 deletions
diff --git a/src/mirall/folder.cpp b/src/mirall/folder.cpp
index 041cda19a..f2f1cfed9 100644
--- a/src/mirall/folder.cpp
+++ b/src/mirall/folder.cpp
@@ -61,6 +61,7 @@ Folder::Folder(const QString &alias, const QString &path, const QString& secondP
, _wipeDb(false)
, _proxyDirty(true)
, _forceSyncOnPollTimeout(false)
+ , _consecutiveFailingSyncs(0)
, _journal(path)
, _csync_ctx(0)
{
@@ -272,12 +273,10 @@ void Folder::slotPollTimerTimeout()
bool forceSyncIntervalExpired =
quint64(_timeSinceLastSync.elapsed()) > MirallConfigFile().forceSyncInterval();
- bool okSyncResult =
- _syncResult.status() == SyncResult::Success ||
- _syncResult.status() == SyncResult::Problem;
+ bool syncAgainAfterFail = _consecutiveFailingSyncs > 0 && _consecutiveFailingSyncs < 3;
if (forceSyncIntervalExpired ||
_forceSyncOnPollTimeout ||
- !okSyncResult) {
+ syncAgainAfterFail) {
if (forceSyncIntervalExpired) {
qDebug() << "** Force Sync, because it has been " << _timeSinceLastSync.elapsed() << "ms "
<< "since the last sync";
@@ -285,8 +284,10 @@ void Folder::slotPollTimerTimeout()
if (_forceSyncOnPollTimeout) {
qDebug() << "** Force Sync, because it was requested";
}
- if (!okSyncResult) {
- qDebug() << "** Force Sync, because the last sync had status: " << _syncResult.statusString();
+ if (syncAgainAfterFail) {
+ qDebug() << "** Force Sync, because the last"
+ << _consecutiveFailingSyncs << "syncs failed, last status:"
+ << _syncResult.statusString();
}
_forceSyncOnPollTimeout = false;
emit scheduleToSync(alias());
@@ -830,6 +831,18 @@ void Folder::slotSyncFinished()
_syncResult.setStatus(SyncResult::Success);
}
+ // Count the number of syncs that have failed in a row.
+ if (_syncResult.status() == SyncResult::Success
+ || _syncResult.status() == SyncResult::Problem)
+ {
+ _consecutiveFailingSyncs = 0;
+ }
+ else
+ {
+ _consecutiveFailingSyncs++;
+ qDebug() << "the last" << _consecutiveFailingSyncs << "syncs failed";
+ }
+
emit syncStateChange();
// The syncFinished result that is to be triggered here makes the folderman
diff --git a/src/mirall/folder.h b/src/mirall/folder.h
index b67e957bf..57ccdd741 100644
--- a/src/mirall/folder.h
+++ b/src/mirall/folder.h
@@ -203,6 +203,7 @@ private:
QString _lastEtag;
QElapsedTimer _timeSinceLastSync;
bool _forceSyncOnPollTimeout;
+ int _consecutiveFailingSyncs;
// For the SocketAPI folder states
QSet<QString> _stateLastSyncItemsWithErrorNew; // gets moved to _stateLastSyncItemsWithError at end of sync