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 e43dbe94d1aa
parent 521122 f9eb88415e06
child 521124 1244522a15c7
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();
   }