Bug 1107656 - Generate unique prefixes for e10s parent-child server connections; r=ochameau
authorPatrick Brosset <pbrosset@mozilla.com>
Tue, 03 Mar 2015 09:44:25 +0100
changeset 232509 563608e9ff4d7b41ccec3fad021b559bc8b878b7
parent 232508 e98ebcdcf9314acd68ed2213dd24910737ab9990
child 232510 6895878594b2399a4410c9c453b75f058c10fb3f
push id11651
push userpbrosset@mozilla.com
push dateMon, 09 Mar 2015 13:37:53 +0000
treeherderfx-team@563608e9ff4d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersochameau
bugs1107656
milestone39.0a1
Bug 1107656 - Generate unique prefixes for e10s parent-child server connections; r=ochameau
toolkit/devtools/Loader.jsm
toolkit/devtools/server/main.js
--- a/toolkit/devtools/Loader.jsm
+++ b/toolkit/devtools/Loader.jsm
@@ -248,16 +248,18 @@ SrcdirProvider.prototype = {
       }
       return this._writeFile(OS.Path.join(dir, "chrome.manifest"), entries.join("\n"));
     }).then(() => {
       Components.manager.addBootstrappedManifestLocation(new FileUtils.File(dir));
     });
   }
 };
 
+var gNextLoaderID = 0;
+
 /**
  * The main devtools API.
  * In addition to a few loader-related details, this object will also include all
  * exports from the main module.  The standard instance of this loader is
  * exported as |devtools| below, but if a fresh copy of the loader is needed,
  * then a new one can also be created.
  */
 this.DevToolsLoader = function DevToolsLoader() {
@@ -273,16 +275,24 @@ DevToolsLoader.prototype = {
     if (!this._provider) {
       this._chooseProvider();
     }
     return this._provider;
   },
 
   _provider: null,
 
+  get id() {
+    if (this._id) {
+      return this._id;
+    } else {
+      return this._id = ++gNextLoaderID;
+    }
+  },
+
   /**
    * A dummy version of require, in case a provider hasn't been chosen yet when
    * this is first called.  This will then be replaced by the real version.
    * @see setProvider
    */
   require: function() {
     if (!this._provider) {
       this._chooseProvider();
@@ -372,17 +382,18 @@ DevToolsLoader.prototype = {
       isWorker: false,
       reportError: Cu.reportError,
       btoa: btoa,
       _Iterator: Iterator,
       loader: {
         lazyGetter: this.lazyGetter,
         lazyImporter: this.lazyImporter,
         lazyServiceGetter: this.lazyServiceGetter,
-        lazyRequireGetter: this.lazyRequireGetter
+        lazyRequireGetter: this.lazyRequireGetter,
+        id: this.id
       },
     };
     // Lazy define console in order to load Console.jsm only when it is used
     XPCOMUtils.defineLazyGetter(this._provider.globals, "console", () => {
       return Cu.import("resource://gre/modules/devtools/Console.jsm", {}).console;
     });
 
     this._provider.load();
--- a/toolkit/devtools/server/main.js
+++ b/toolkit/devtools/server/main.js
@@ -960,18 +960,23 @@ var DebuggerServer = {
    * that all our actors have names beginning with |aForwardingPrefix + '/'|.
    * In particular, the root actor's name will be |aForwardingPrefix + '/root'|.
    */
   _onConnection: function DS_onConnection(aTransport, aForwardingPrefix, aNoRootActor = false) {
     let connID;
     if (aForwardingPrefix) {
       connID = aForwardingPrefix + "/";
     } else {
-      connID = "conn" + this._nextConnID++ + '.';
+      // Multiple servers can be started at the same time, and when that's the
+      // case, they are loaded in separate devtools loaders.
+      // So, use the current loader ID to prefix the connection ID and make it
+      // unique.
+      connID = "server" + loader.id + ".conn" + this._nextConnID++ + '.';
     }
+
     let conn = new DebuggerServerConnection(connID, aTransport);
     this._connections[connID] = conn;
 
     // Create a root actor for the connection and send the hello packet.
     if (!aNoRootActor) {
       conn.rootActor = this.createRootActor(conn);
       if (aForwardingPrefix)
         conn.rootActor.actorID = aForwardingPrefix + "/root";