Bug 913950 - close all existing ports on worker termination. r=mixedpuppy
authorMark Hammond <mhammond@skippinet.com.au>
Tue, 10 Sep 2013 10:31:15 +1000
changeset 146324 41539c7111e0cebc2e0e8a2c66b4d5c2410ff3ce
parent 146323 23e8350ce32c4ef3d14e6955336360c8d21eef6d
child 146325 dedfb60795aab1b72cf6264e2d1bd3f1011fba70
push id25252
push usercbook@mozilla.com
push dateTue, 10 Sep 2013 08:27:30 +0000
treeherdermozilla-central@9f9733d4c20e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmixedpuppy
bugs913950
milestone26.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 913950 - close all existing ports on worker termination. r=mixedpuppy
toolkit/components/social/FrameWorker.jsm
--- a/toolkit/components/social/FrameWorker.jsm
+++ b/toolkit/components/social/FrameWorker.jsm
@@ -122,22 +122,26 @@ WorkerHandle.prototype = {
   // browser element.
   terminate: function terminate() {
     let url = this._worker.options.url;
     if (!(url in workerCache)) {
       // terminating an already terminated worker - ignore it
       return;
     }
     delete workerCache[url];
+    // close all the ports we have handed out.
+    for (let [portid, port] of this._worker.ports) {
+      port.close();
+    }
+    this._worker.ports.clear();
+    this._worker.ports = null;
     this._worker.browserPromise.then(browser => {
       browser.parentNode.removeChild(browser);
     });
     // wipe things out just incase other reference have snuck out somehow...
-    this._worker.ports.clear();
-    this._worker.ports = null;
     this._worker.browserPromise = null;
     this._worker = null;
   }
 };
 
 // The port that lives in the parent chrome process.  The other end of this
 // port is the "client" port in the content process, which itself is just a
 // shim which shuttles messages to/from the worker itself.