[tor-commits] [snowflake/master] Null out relay after closing

arlo at torproject.org arlo at torproject.org
Wed Jul 10 15:58:46 UTC 2019


commit c12fcbeb856fcb2ea5431059bd6712d91e5ac1b5
Author: Arlo Breault <arlolra at gmail.com>
Date:   Sun Jul 7 18:44:56 2019 +0200

    Null out relay after closing
    
    This was probably meant to be `@relay = null` is the coffeescript.
---
 proxy/proxypair.js | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/proxy/proxypair.js b/proxy/proxypair.js
index c162807..674ac18 100644
--- a/proxy/proxypair.js
+++ b/proxy/proxypair.js
@@ -121,18 +121,18 @@ class ProxyPair {
     if (peer_ip != null) {
       params.push(["client_ip", peer_ip]);
     }
-    this.relay = WS.makeWebsocket(this.relayAddr, params);
+    var relay = this.relay = WS.makeWebsocket(this.relayAddr, params);
     this.relay.label = 'websocket-relay';
     this.relay.onopen = () => {
       if (this.timer) {
         clearTimeout(this.timer);
         this.timer = 0;
       }
-      log(this.relay.label + ' connected!');
+      log(relay.label + ' connected!');
       return snowflake.ui.setStatus('connected');
     };
     this.relay.onclose = () => {
-      log(this.relay.label + ' closed.');
+      log(relay.label + ' closed.');
       snowflake.ui.setStatus('disconnected.');
       snowflake.ui.setActive(false);
       snowflake.state = Snowflake.MODE.INIT;
@@ -146,8 +146,8 @@ class ProxyPair {
       if (0 === this.timer) {
         return;
       }
-      log(this.relay.label + ' timed out connecting.');
-      return this.relay.onclose();
+      log(relay.label + ' timed out connecting.');
+      return relay.onclose();
     }), 5000);
   }
 
@@ -172,7 +172,6 @@ class ProxyPair {
 
   // Close both WebRTC and websocket.
   close() {
-    var relay;
     if (this.timer) {
       clearTimeout(this.timer);
       this.timer = 0;
@@ -181,11 +180,12 @@ class ProxyPair {
     if (this.webrtcIsReady()) {
       this.client.close();
     }
+    this.client = null;
     if (this.relayIsReady()) {
       this.relay.close();
     }
-    relay = null;
-    return this.onCleanup();
+    this.relay = null;
+    this.onCleanup();
   }
 
   flush() {





More information about the tor-commits mailing list