зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1536794 - Close httpd's Connection when closing the remote agent's server. r=ato
This fixes the browser mochitest which currently timesout when calling server.close() It started to timeout when the patch related to websocket handshake landed. Depends on D24219 Differential Revision: https://phabricator.services.mozilla.com/D24220 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
8f9717d1e8
Коммит
4c3f075b45
|
@ -13,9 +13,14 @@ XPCOMUtils.defineLazyGetter(this, "log", Log.get);
|
|||
XPCOMUtils.defineLazyServiceGetter(this, "UUIDGen", "@mozilla.org/uuid-generator;1", "nsIUUIDGenerator");
|
||||
|
||||
class Connection {
|
||||
constructor(transport) {
|
||||
/**
|
||||
* @param WebSocketDebuggerTransport transport
|
||||
* @param httpd.js's Connection httpdConnection
|
||||
*/
|
||||
constructor(transport, httpdConnection) {
|
||||
this.id = UUIDGen.generateUUID().toString();
|
||||
this.transport = transport;
|
||||
this.httpdConnection = httpdConnection;
|
||||
|
||||
this.transport.hooks = this;
|
||||
this.transport.ready();
|
||||
|
@ -93,6 +98,11 @@ class Connection {
|
|||
close() {
|
||||
this.transport.close();
|
||||
this.sessions.clear();
|
||||
|
||||
// In addition to the WebSocket transport, we also have to close the Connection
|
||||
// used internaly within httpd.js. Otherwise the server doesn't shut down correctly
|
||||
// and keep these Connection instances alive.
|
||||
this.httpdConnection.close();
|
||||
}
|
||||
|
||||
onClosed(status) {}
|
||||
|
|
|
@ -34,7 +34,7 @@ class TabTarget extends Target {
|
|||
|
||||
disconnect() {
|
||||
Services.obs.removeObserver(this, "message-manager-disconnect");
|
||||
// TODO(ato): Disconnect existing client sockets
|
||||
super.disconnect();
|
||||
}
|
||||
|
||||
get id() {
|
||||
|
|
|
@ -24,12 +24,21 @@ class Target {
|
|||
this.sessions = new Map();
|
||||
}
|
||||
|
||||
/**
|
||||
* Close all pending connections to this target.
|
||||
*/
|
||||
disconnect() {
|
||||
for (const [conn] of this.sessions) {
|
||||
conn.close();
|
||||
}
|
||||
}
|
||||
|
||||
// nsIHttpRequestHandler
|
||||
|
||||
async handle(request, response) {
|
||||
const so = await WebSocketServer.upgrade(request, response);
|
||||
const transport = new WebSocketDebuggerTransport(so);
|
||||
const conn = new Connection(transport);
|
||||
const conn = new Connection(transport, response._connection);
|
||||
this.sessions.set(conn, new this.sessionClass(conn, this));
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче