mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 19:35:51 +00:00
Bug 1402267 - Restart the SessionWorker each time there are failures reported as much as defined in the 'browser.sessionstore.max_write_failures' pref. r=ttaubert
MozReview-Commit-ID: 91vOcbmhFmj --HG-- extra : rebase_source : 5d2a5c99cb921f7495c3c69b79a019dc463b09a6
This commit is contained in:
parent
3bb8a8db6c
commit
6c7f044a8d
@ -890,6 +890,8 @@ pref("browser.sessionstore.debug.no_auto_updates", false);
|
||||
pref("browser.sessionstore.cleanup.forget_closed_after", 1209600000);
|
||||
// Maximum number of bytes of DOMSessionStorage data we collect per origin.
|
||||
pref("browser.sessionstore.dom_storage_limit", 2048);
|
||||
// Amount of failed SessionFile writes until we restart the worker.
|
||||
pref("browser.sessionstore.max_write_failures", 5);
|
||||
|
||||
// allow META refresh by default
|
||||
pref("accessibility.blockautorefresh", false);
|
||||
|
@ -58,6 +58,9 @@ const PREF_MAX_UPGRADE_BACKUPS = "browser.sessionstore.upgradeBackup.maxUpgradeB
|
||||
const PREF_MAX_SERIALIZE_BACK = "browser.sessionstore.max_serialize_back";
|
||||
const PREF_MAX_SERIALIZE_FWD = "browser.sessionstore.max_serialize_forward";
|
||||
|
||||
XPCOMUtils.defineLazyPreferenceGetter(this, "kMaxWriteFailures",
|
||||
"browser.sessionstore.max_write_failures", 5);
|
||||
|
||||
this.SessionFile = {
|
||||
/**
|
||||
* Read the contents of the session file, asynchronously.
|
||||
@ -187,6 +190,12 @@ var SessionFileInternal = {
|
||||
// Used for error reporting.
|
||||
_failures: 0,
|
||||
|
||||
// Object that keeps statistics that should help us make informed decisions
|
||||
// about the current status of the worker.
|
||||
_workerHealth: {
|
||||
failures: 0
|
||||
},
|
||||
|
||||
// Resolved once initialization is complete.
|
||||
// The promise never rejects.
|
||||
_deferredInitialized: PromiseUtils.defer(),
|
||||
@ -231,7 +240,8 @@ var SessionFileInternal = {
|
||||
|
||||
if (!SessionStore.isFormatVersionCompatible(parsed.version || ["sessionrestore", 0] /* fallback for old versions*/)) {
|
||||
// Skip sessionstore files that we don't understand.
|
||||
Cu.reportError("Cannot extract data from Session Restore file " + path + ". Wrong format/version: " + JSON.stringify(parsed.version) + ".");
|
||||
Cu.reportError("Cannot extract data from Session Restore file " + path +
|
||||
". Wrong format/version: " + JSON.stringify(parsed.version) + ".");
|
||||
continue;
|
||||
}
|
||||
result = {
|
||||
@ -332,6 +342,19 @@ var SessionFileInternal = {
|
||||
return SessionWorker.post(...args);
|
||||
},
|
||||
|
||||
/**
|
||||
* For good measure, terminate the worker when we've had over `kMaxWriteFailures`
|
||||
* amount of failures to deal with. This will spawn a fresh worker upon the next
|
||||
* write.
|
||||
* This also resets the `_workerHealth` stats.
|
||||
*/
|
||||
_checkWorkerHealth() {
|
||||
if (this._workerHealth.failures >= kMaxWriteFailures) {
|
||||
SessionWorker.terminate();
|
||||
this._workerHealth.failures = 0;
|
||||
}
|
||||
},
|
||||
|
||||
write(aData) {
|
||||
if (RunState.isClosed) {
|
||||
return Promise.reject(new Error("SessionFile is closed"));
|
||||
@ -367,6 +390,7 @@ var SessionFileInternal = {
|
||||
// Catch and report any errors.
|
||||
console.error("Could not write session state file ", err, err.stack);
|
||||
this._failures++;
|
||||
this._workerHealth.failures++;
|
||||
// By not doing anything special here we ensure that |promise| cannot
|
||||
// be rejected anymore. The shutdown/cleanup code at the end of the
|
||||
// function will thus always be executed.
|
||||
@ -395,6 +419,8 @@ var SessionFileInternal = {
|
||||
|
||||
if (isFinalWrite) {
|
||||
Services.obs.notifyObservers(null, "sessionstore-final-state-write-complete");
|
||||
} else {
|
||||
this._checkWorkerHealth();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user