Bug 972129 - introduce a custom backoff schedule if failure is due to identity manager not being ready. r=rnewman

This commit is contained in:
Mark Hammond 2014-02-13 17:07:53 +11:00
parent d8548f5d88
commit 225c7f7993
2 changed files with 18 additions and 0 deletions

View File

@ -54,6 +54,11 @@ HMAC_EVENT_INTERVAL: 600000,
// How long to wait between sync attempts if the Master Password is locked.
MASTER_PASSWORD_LOCKED_RETRY_INTERVAL: 15 * 60 * 1000, // 15 minutes
// How long to initially wait between sync attempts if the identity manager is
// not ready. As we expect this to become ready relatively quickly, we retry
// in (IDENTITY_NOT_READY_RETRY_INTERVAL * num_failures) seconds.
IDENTITY_NOT_READY_RETRY_INTERVAL: 5 * 1000, // 5 seconds
// Separate from the ID fetch batch size to allow tuning for mobile.
MOBILE_BATCH_SIZE: 50,

View File

@ -30,6 +30,8 @@ SyncScheduler.prototype = {
LOGIN_FAILED_INVALID_PASSPHRASE,
LOGIN_FAILED_LOGIN_REJECTED],
_loginNotReadyCounter: 0,
/**
* The nsITimer object that schedules the next sync. See scheduleNextSync().
*/
@ -113,6 +115,10 @@ SyncScheduler.prototype = {
// we'll handle that later
Status.resetBackoff();
// Reset the loginNotReady counter, just in-case the user signs in
// as another user and re-hits the not-ready state.
this._loginNotReadyCounter = 0;
this.globalScore = 0;
break;
case "weave:service:sync:finish":
@ -155,6 +161,13 @@ SyncScheduler.prototype = {
this._log.debug("Couldn't log in: master password is locked.");
this._log.trace("Scheduling a sync at MASTER_PASSWORD_LOCKED_RETRY_INTERVAL");
this.scheduleAtInterval(MASTER_PASSWORD_LOCKED_RETRY_INTERVAL);
} else if (Status.login == LOGIN_FAILED_NOT_READY) {
this._loginNotReadyCounter++;
this._log.debug("Couldn't log in: identity not ready.");
this._log.trace("Scheduling a sync at IDENTITY_NOT_READY_RETRY_INTERVAL * " +
this._loginNotReadyCounter);
this.scheduleAtInterval(IDENTITY_NOT_READY_RETRY_INTERVAL *
this._loginNotReadyCounter);
} else if (this._fatalLoginStatus.indexOf(Status.login) == -1) {
// Not a fatal login error, just an intermittent network or server
// issue. Keep on syncin'.