summaryrefslogtreecommitdiff
path: root/src/or
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2007-01-18 03:38:24 +0000
committerRoger Dingledine <arma@torproject.org>2007-01-18 03:38:24 +0000
commita3eaabfeb2fd5ccbdf0f158bb95d545beb34ab21 (patch)
tree19f9652a73e4593abbcad5d02ef787a363ca47ce /src/or
parentb470da0e5acbd1ad55f8d401f4e8de42d15b86d5 (diff)
downloadtor-a3eaabfeb2fd5ccbdf0f158bb95d545beb34ab21.tar.gz
tor-a3eaabfeb2fd5ccbdf0f158bb95d545beb34ab21.zip
Be willing to read or write on local connections (e.g. controller
connections) even when the global rate limiting buckets are empty. svn:r9368
Diffstat (limited to 'src/or')
-rw-r--r--src/or/connection.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/or/connection.c b/src/or/connection.c
index 9d71db5d4b..fbd2a8aa41 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -1099,8 +1099,16 @@ retry_all_listeners(int force, smartlist_t *replaced_conns,
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 @@ connection_bucket_read_limit(connection_t *conn)
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 @@ connection_bucket_write_limit(connection_t *conn)
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 @@ connection_outbuf_too_full(connection_t *conn)
* 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.
*