bug 1523104: remote: correctly unregister accepted listener in TargetListener; r=ato
authorAlexandre Poirot <poirot.alex@gmail.com>
Tue, 05 Mar 2019 12:59:16 -0800
changeset 521123 e43dbe94d1aa420cfb48d25bb022a9578f6e7fae
parent 521122 f9eb88415e06e11f3bf58ead711168f633111283
child 521124 1244522a15c7f1e97fb6b9f5f1924c12554d668c
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersato
bugs1523104
milestone67.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 1523104: remote: correctly unregister accepted listener in TargetListener; r=ato
remote/TargetListener.jsm
--- a/remote/TargetListener.jsm
+++ b/remote/TargetListener.jsm
@@ -20,35 +20,36 @@ const {SocketListener} = ChromeUtils.imp
  * The session's lifetime is equal to the lifetime of the debugger connection.
  */
 class TargetListener {
   constructor(target) {
     this.target = target;
     this.listener = null;
     this.sessions = new Map();
     this.nextConnID = 0;
+    this.onConnectionAccepted = this.onConnectionAccepted.bind(this);
   }
 
   get listening() {
     return !!this.listener && this.listener.listening;
   }
 
   listen() {
     if (this.listener) {
       return;
     }
 
     this.listener = new SocketListener();
-    this.listener.on("accepted", this.onConnectionAccepted.bind(this));
+    this.listener.on("accepted", this.onConnectionAccepted);
 
     this.listener.listen("ws", 0 /* atomically allocated port */);
   }
 
   close() {
-    this.listener.off("accepted", this.onConnectionAccepted.bind(this));
+    this.listener.off("accepted", this.onConnectionAccepted);
     for (const [conn, session] of this.sessions) {
       session.destructor();
       conn.close();
     }
     this.listener.close();
     this.listener = null;
     this.sessions.clear();
   }