[tor-commits] [flashproxy/master] Check that socket is defined before checking bufferedAmount.

dcf at torproject.org dcf at torproject.org
Tue Jun 11 15:57:44 UTC 2013


commit cba4501d23f6734fea4965f458ad99204e7585c9
Author: David Fifield <david at bamsoftware.com>
Date:   Tue Jun 11 08:56:39 2013 -0700

    Check that socket is defined before checking bufferedAmount.
    
    client_s and relay_s are not always both defined now. This was the cause
    of #9009.
---
 ChangeLog           |    5 +++++
 proxy/flashproxy.js |    4 ++--
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 5e03710..791224c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -22,6 +22,11 @@
     window.navigator.language when possible. Patch by Arlo Breault.
     Fixes bug 8827.
 
+  o Proxies now attempt to connect to the client first, and only connect
+    to the relay after the client connection is successful. This is
+    meant to reduce the number of connections to the relay when clients
+    haven't set up port forwarding. Introduced bug 9009, later fixed. 
+
 Changes in version 1.1
   o Programs that use certificate pins now take a --disable-pin option
     that causes pins to be ignored.
diff --git a/proxy/flashproxy.js b/proxy/flashproxy.js
index d52a24b..cb54f23 100644
--- a/proxy/flashproxy.js
+++ b/proxy/flashproxy.js
@@ -813,8 +813,8 @@ function ProxyPair(client_addr, relay_addr, rate_limit) {
             this.relay_s.close();
         }
 
-        if (this.r2c_schedule.length > 0 || this.client_s.bufferedAmount > 0
-            || this.c2r_schedule.length > 0 || this.relay_s.bufferedAmount > 0)
+        if (this.r2c_schedule.length > 0 || (is_open(this.client_s) && this.client_s.bufferedAmount > 0)
+            || this.c2r_schedule.length > 0 || (is_open(this.relay_s) && this.relay_s.bufferedAmount > 0))
             this.flush_timeout_id = setTimeout(this.flush.bind(this), this.rate_limit.when() * 1000);
     };
 }



More information about the tor-commits mailing list