Browse Source

Read at most 32 cells from socket.

Steven Engler 4 years ago
parent
commit
f03cfc6248
1 changed files with 12 additions and 4 deletions
  1. 12 4
      src/core/or/safe_connection.c

+ 12 - 4
src/core/or/safe_connection.c

@@ -801,11 +801,19 @@ safe_or_connection_max_bytes_can_read(safe_or_connection_t *safe_or_conn,
   // note: that would be a bad way to do it, since instead we should borrow
   // some space from the global bucket, and then commit it once the read
   // is actually finished
-  if (use_conn_buckets) {
-    return token_bucket_rw_get_read(&safe_or_conn->bucket);
-  } else {
-    return SIZE_MAX;
+
+  size_t cell_network_size = \
+    get_cell_network_size(safe_or_conn->wide_circ_ids?1:0);
+  size_t bucket_max = token_bucket_rw_get_read(&safe_or_conn->bucket);
+
+  size_t rv = 32*cell_network_size;
+  // this is the limit that 'connection_bucket_get_share()' uses
+
+  if (use_conn_buckets && rv > bucket_max) {
+    rv = bucket_max;
   }
+
+  return rv;
 }
 
 static size_t