[or-cvs] r9368: Be willing to read or write on local connections (e.g. contr (in tor/trunk: . src/or)

arma at seul.org arma at seul.org
Thu Jan 18 03:38:27 UTC 2007


Author: arma
Date: 2007-01-17 22:38:24 -0500 (Wed, 17 Jan 2007)
New Revision: 9368

Modified:
   tor/trunk/ChangeLog
   tor/trunk/src/or/connection.c
Log:
Be willing to read or write on local connections (e.g. controller
connections) even when the global rate limiting buckets are empty.


Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog	2007-01-18 03:35:13 UTC (rev 9367)
+++ tor/trunk/ChangeLog	2007-01-18 03:38:24 UTC (rev 9368)
@@ -19,6 +19,8 @@
     - Servers decline directory requests much more aggressively when
       they're low on bandwidth. Otherwise they end up queueing more and
       more directory responses, which can't be good for latency.
+    - Be willing to read or write on local connections (e.g. controller
+      connections) even when the global rate limiting buckets are empty.
 
   o Minor bugfixes:
     - When computing clock skew from directory HTTP headers, consider what

Modified: tor/trunk/src/or/connection.c
===================================================================
--- tor/trunk/src/or/connection.c	2007-01-18 03:35:13 UTC (rev 9367)
+++ tor/trunk/src/or/connection.c	2007-01-18 03:38:24 UTC (rev 9368)
@@ -1099,8 +1099,16 @@
 
 extern int global_read_bucket, global_write_bucket;
 
+/** Did our global write bucket run dry last second? If so, we are
+ * likely to run dry again this second, so be stingy with the tokens
+ * we just put in. */
 static int global_write_bucket_empty_last_second = 0;
 
+/** Helper function to decide how many bytes out of <b>global_bucket</b>
+ * we're willing to use for this transaction. <b>base</b> is the size
+ * of a cell on the network; <b>priority</b> says whether we should
+ * write many of them or just a few; and <b>conn_bucket</b> (if
+ * non-negative) provides an upper limit for our answer. */
 static int
 connection_bucket_round_robin(int base, int priority,
                               int global_bucket, int conn_bucket)
@@ -1142,6 +1150,10 @@
     or_connection_t *or_conn = TO_OR_CONN(conn);
     conn_bucket = or_conn->read_bucket;
   }
+  if (conn_is_internal(conn->addr, 0)) {
+    /* be willing to read on local conns even if our buckets are empty */
+    return conn_bucket>=0 ? conn_bucket : 2**14;
+  }
   return connection_bucket_round_robin(base, priority,
                                        global_read_bucket, conn_bucket);
 }
@@ -1154,6 +1166,10 @@
                CELL_NETWORK_SIZE : RELAY_PAYLOAD_SIZE;
   int priority = conn->type != CONN_TYPE_DIR;
 
+  if (conn_is_internal(conn->addr, 0)) {
+    /* be willing to write to local conns even if our buckets are empty */
+    return conn->outbuf_flushlen;
+  }
   return connection_bucket_round_robin(base, priority, global_write_bucket,
                                        conn->outbuf_flushlen);
 }
@@ -1590,7 +1606,7 @@
  * from connection_write_to_buf() when an entire TLS record is ready.
  *
  * Update conn-\>timestamp_lastwritten to now, and call flush_buf
- * or flush_buf_tls appropriately. If it succeeds and there no more
+ * or flush_buf_tls appropriately. If it succeeds and there are no more
  * more bytes on conn->outbuf, then call connection_finished_flushing
  * on it too.
  *



More information about the tor-commits mailing list