diff --git a/toolkit/devtools/server/main.js b/toolkit/devtools/server/main.js index 6d7dce7b7221..71638ee5e19d 100644 --- a/toolkit/devtools/server/main.js +++ b/toolkit/devtools/server/main.js @@ -150,15 +150,20 @@ var DebuggerServer = { * method returns, the debugger server must be initialized again before use. */ destroy: function DS_destroy() { - if (Object.keys(this._connections).length == 0) { - this.closeListener(); - this.globalActorFactories = {}; - this.tabActorFactories = {}; - delete this._allowConnection; - this._transportInitialized = false; - this._initialized = false; - dumpn("Debugger server is shut down."); + if (!this._initialized) { + return; } + + for (let connID of Object.getOwnPropertyNames(this._connections)) { + this._connections[connID].close(); + } + this.closeListener(); + this.globalActorFactories = {}; + this.tabActorFactories = {}; + delete this._allowConnection; + this._transportInitialized = false; + this._initialized = false; + dumpn("Debugger server is shut down."); }, /** @@ -525,6 +530,10 @@ DebuggerServerConnection.prototype = { _transport: null, get transport() { return this._transport }, + close: function() { + this._transport.close(); + }, + send: function DSC_send(aPacket) { this.transport.send(aPacket); }, diff --git a/toolkit/devtools/server/transport.js b/toolkit/devtools/server/transport.js index 3a27c0dc7c64..a8a8c444075a 100644 --- a/toolkit/devtools/server/transport.js +++ b/toolkit/devtools/server/transport.js @@ -173,7 +173,10 @@ DebuggerTransport.prototype = { onStopRequest: makeInfallible(function DT_onStopRequest(aRequest, aContext, aStatus) { this.close(); - this.hooks.onClosed(aStatus); + if (this.hooks) { + this.hooks.onClosed(aStatus); + this.hooks = null; + } }, "DebuggerTransport.prototype.onStopRequest"), onDataAvailable: @@ -292,7 +295,10 @@ LocalDebuggerTransport.prototype = { delete this.other; other.close(); } - this.hooks.onClosed(); + if (this.hooks) { + this.hooks.onClosed(); + this.hooks = null; + } }, /**