mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-31 21:21:08 +00:00
Bug 1076597 - Fix Settings API shutdown race condition. r=bent
This commit is contained in:
parent
9261b9ccdd
commit
343378644a
@ -743,20 +743,33 @@ let SettingsRequestManager = {
|
||||
}
|
||||
},
|
||||
|
||||
removeMessageManager: function(aMsgMgr){
|
||||
removeMessageManager: function(aMsgMgr, aPrincipal) {
|
||||
if (DEBUG) debug("Removing message manager");
|
||||
this.removeObserver(aMsgMgr);
|
||||
let closedLockIDs = [];
|
||||
let lockIDs = Object.keys(this.lockInfo);
|
||||
for (let i in lockIDs) {
|
||||
if (this.lockInfo[lockIDs[i]]._mm == aMsgMgr) {
|
||||
if (DEBUG) debug("Removing lock " + lockIDs[i] + " due to process close/crash");
|
||||
closedLockIDs.push(lockIDs[i]);
|
||||
let lock = this.lockInfo[lockIDs[i]];
|
||||
if (lock._mm == aMsgMgr) {
|
||||
let is_finalizing = false;
|
||||
for (let task_index in lock.tasks) {
|
||||
if (lock.tasks[task_index].operation === "finalize") {
|
||||
is_finalizing = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!is_finalizing) {
|
||||
this.queueTask("finalize", {lockID: lockIDs[i]}, aPrincipal).then(
|
||||
function() {
|
||||
if (DEBUG) debug("Lock " + lockIDs[i] + " with dead message manager finalized");
|
||||
},
|
||||
function(error) {
|
||||
if (DEBUG) debug("Lock " + lockIDs[i] + " with dead message manager NOT FINALIZED due to error: " + error);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (let i in closedLockIDs) {
|
||||
this.removeLock(closedLockIDs[i]);
|
||||
}
|
||||
},
|
||||
|
||||
receiveMessage: function(aMessage) {
|
||||
@ -812,7 +825,7 @@ let SettingsRequestManager = {
|
||||
switch (aMessage.name) {
|
||||
case "child-process-shutdown":
|
||||
if (DEBUG) debug("Child process shutdown received.");
|
||||
this.removeMessageManager(mm);
|
||||
this.removeMessageManager(mm, aMessage.principal);
|
||||
break;
|
||||
case "Settings:RegisterForMessages":
|
||||
if (!SettingsPermissions.hasSomeReadPermission(aMessage.principal)) {
|
||||
|
Loading…
Reference in New Issue
Block a user