Bug 1107656 - Generate unique prefixes for e10s parent-child server connections; r=ochameau
--- 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";