[tor-commits] [stegotorus/master] Two subtle chopper bugfixes:

zwol at torproject.org zwol at torproject.org
Fri Jul 20 23:17:08 UTC 2012


commit 4f3ccfc31308ea4703300cbbfeb7a463eb0d9dfb
Author: Zack Weinberg <zackw at cmu.edu>
Date:   Wed Jun 13 17:29:17 2012 -0400

    Two subtle chopper bugfixes:
    
    * Don't kill the connection just because not enough data has arrived
      yet for us to desteg the handshake message.
    * If there's no data to send, but there is an EOF to send, and none
      of the existing connections can send, we need to open a new connection.
---
 src/protocol/chop.cc |   23 +++++++++++++++--------
 1 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/src/protocol/chop.cc b/src/protocol/chop.cc
index 20ba563..a30dd94 100644
--- a/src/protocol/chop.cc
+++ b/src/protocol/chop.cc
@@ -705,14 +705,16 @@ chop_circuit_t::send()
     dead_cycles++;
     log_debug(this, "%u dead cycles", dead_cycles);
 
-    // If there was real data and we didn't make any progress on it,
-    // or if there are no downstream connections at all, and we're the
-    // client, try opening new connections.  If we're the server, we
-    // have to just twiddle our thumbs and hope the client does that.
-    // Note that due to the sliding window of receive blocks, there is
-    // a hard upper limit of 127 outstanding connections (that is,
-    // half the receive window).
-    if ((avail0 > 0 && downstreams.size() < 127) || downstreams.empty()) {
+    // If there was real data or an EOF to send, and we didn't make
+    // any progress on it, or if there are no downstream connections
+    // at all, and we're the client, try opening new connections.  If
+    // we're the server, we have to just twiddle our thumbs and hope
+    // the client does that.  Note that due to the sliding window of
+    // receive blocks, there is a hard upper limit of 127 outstanding
+    // connections (that is, half the receive window).
+    if (downstreams.empty() ||
+        (downstreams.size() < 127 &&
+         (avail0 > 0 || (upstream_eof && !sent_fin)))) {
       if (config->mode != LSN_SIMPLE_SERVER)
         circuit_reopen_downstreams(this);
       else
@@ -1213,6 +1215,11 @@ chop_conn_t::recv()
   if (steg->receive(recv_pending))
     return -1;
 
+  // If that succeeded but did not copy anything into recv_pending,
+  // wait for more data.
+  if (evbuffer_get_length(recv_pending) == 0)
+    return 0;
+
   if (!upstream) {
     // Try to receive a handshake.
     if (recv_handshake())





More information about the tor-commits mailing list