Bug 741960 - Fuzz backoff times up to 25% more to avoid client lock-stepping. r=rnewman

This commit is contained in:
Nick Alexander 2012-08-02 22:00:43 -07:00
parent f8dee3f4cb
commit 4d1ff3cc48

View File

@ -226,6 +226,21 @@ public class SyncAdapter extends AbstractThreadedSyncAdapter implements GlobalSe
return delayMilliseconds() > 0;
}
/**
* Request that no sync start right away. A new sync won't start until
* at least <code>backoff</code> milliseconds from now.
*
* @param backoff time to wait in milliseconds.
*/
@Override
public void requestBackoff(long backoff) {
if (backoff > 0) {
// Fuzz the backoff time (up to 25% more) to prevent client lock-stepping; agrees with desktop.
backoff = backoff + Math.round((double) backoff * 0.25d * Math.random());
this.extendEarliestNextSync(System.currentTimeMillis() + backoff);
}
}
/**
* Asynchronously request an immediate sync, optionally syncing only the given
* named stages.
@ -530,13 +545,6 @@ public class SyncAdapter extends AbstractThreadedSyncAdapter implements GlobalSe
Logger.trace(LOG_TAG, "Stage completed: " + currentState);
}
@Override
public void requestBackoff(long backoff) {
if (backoff > 0) {
this.extendEarliestNextSync(System.currentTimeMillis() + backoff);
}
}
@Override
public synchronized String getAccountGUID() {
String accountGUID = mAccountManager.getUserData(localAccount, Constants.ACCOUNT_GUID);