Bug 991499 - WifiWorker still try to send message to component which is already shutdown. r=vchang, a=lsblakk
authorDimi Lee <dlee@mozilla.com>
Thu, 03 Apr 2014 18:10:16 +0800
changeset 193110 c0c76505c6dce58f20a947d79e51623f0e69fda8
parent 193109 00962671d272c5ec92f5f5aa7eb8a78a686ae34a
child 193111 8fa6a5ec575833335060073f78184f34bcdf8b18
push id474
push userasasaki@mozilla.com
push dateMon, 02 Jun 2014 21:01:02 +0000
treeherdermozilla-release@967f4cf1b31c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvchang, lsblakk
bugs991499
milestone30.0a2
Bug 991499 - WifiWorker still try to send message to component which is already shutdown. r=vchang, a=lsblakk
dom/wifi/WifiWorker.js
--- a/dom/wifi/WifiWorker.js
+++ b/dom/wifi/WifiWorker.js
@@ -2457,18 +2457,22 @@ WifiWorker.prototype = {
     this._domManagers.forEach(function(manager) {
       // Note: We should never have a dead message manager here because we
       // observe our child message managers shutting down, below.
       manager.sendAsyncMessage("WifiManager:" + message, data);
     });
   },
 
   _sendMessage: function(message, success, data, msg) {
-    msg.manager.sendAsyncMessage(message + (success ? ":OK" : ":NO"),
-                                 { data: data, rid: msg.rid, mid: msg.mid });
+    try {
+      msg.manager.sendAsyncMessage(message + (success ? ":OK" : ":NO"),
+                                   { data: data, rid: msg.rid, mid: msg.mid });
+    } catch (e) {
+      debug("sendAsyncMessage error : " + e);
+    }
     this._splicePendingRequest(msg);
   },
 
   _domRequest: [],
 
   _splicePendingRequest: function(msg) {
     for (let i = 0; i < this._domRequest.length; i++) {
       if (this._domRequest[i].msg === msg) {
@@ -2501,17 +2505,21 @@ WifiWorker.prototype = {
     // Note: By the time we receive child-process-shutdown, the child process
     // has already forgotten its permissions so we do this before the
     // permissions check.
     if (aMessage.name === "child-process-shutdown") {
       let i;
       if ((i = this._domManagers.indexOf(msg.manager)) != -1) {
         this._domManagers.splice(i, 1);
       }
-
+      for (i = this._domRequest.length - 1; i >= 0; i--) {
+        if (this._domRequest[i].msg.manager === msg.manager) {
+          this._domRequest.splice(i, 1);
+        }
+      }
       return;
     }
 
     if (!aMessage.target.assertPermission("wifi-manage")) {
       return;
     }
 
     // We are interested in DOMRequests only.