[or-cvs] [tor/master 1/2] factor out rate/burst setting. no actual changes.
arma at torproject.org
arma at torproject.org
Sun Aug 15 08:06:38 UTC 2010
Author: Roger Dingledine <arma at torproject.org>
Date: Sun, 15 Aug 2010 02:27:07 -0400
Subject: factor out rate/burst setting. no actual changes.
Commit: 2bc1842aaac1119a840b8ed3fa815c6f71053ac7
---
src/or/connection_or.c | 36 +++++++++++++++++++++++-------------
1 files changed, 23 insertions(+), 13 deletions(-)
diff --git a/src/or/connection_or.c b/src/or/connection_or.c
index 405df15..da5966c 100644
--- a/src/or/connection_or.c
+++ b/src/or/connection_or.c
@@ -349,21 +349,17 @@ connection_or_digest_is_known_relay(const char *id_digest)
return 0;
}
-/** If we don't necessarily know the router we're connecting to, but we
- * have an addr/port/id_digest, then fill in as much as we can. Start
- * by checking to see if this describes a router we know. */
-static void
-connection_or_init_conn_from_address(or_connection_t *conn,
- const tor_addr_t *addr, uint16_t port,
- const char *id_digest,
- int started_here)
+/** Set the per-conn read and write limits for <b>conn</b>. If it's a known
+ * relay, we will rely on the global read and write buckets, so give it
+ * per-conn limits that are big enough they'll never matter. But if it's
+ * not a known relay, first check if we set PerConnBwRate/Burst, then
+ * check if the consensus sets them, else default to 'big enough'.
+ */
+static void connection_or_set_rate_burst(or_connection_t *conn,
+ or_options_t *options)
{
- or_options_t *options = get_options();
int rate, burst; /* per-connection rate limiting params */
- routerinfo_t *r = router_get_by_digest(id_digest);
- connection_or_set_identity_digest(conn, id_digest);
-
- if (connection_or_digest_is_known_relay(id_digest)) {
+ if (connection_or_digest_is_known_relay(conn->identity_digest)) {
/* It's in the consensus, or we have a descriptor for it meaning it
* was probably in a recent consensus. It's a recognized relay:
* give it full bandwidth. */
@@ -383,6 +379,20 @@ connection_or_init_conn_from_address(or_connection_t *conn,
conn->bandwidthrate = rate;
conn->read_bucket = conn->write_bucket = conn->bandwidthburst = burst;
+}
+
+/** If we don't necessarily know the router we're connecting to, but we
+ * have an addr/port/id_digest, then fill in as much as we can. Start
+ * by checking to see if this describes a router we know. */
+static void
+connection_or_init_conn_from_address(or_connection_t *conn,
+ const tor_addr_t *addr, uint16_t port,
+ const char *id_digest,
+ int started_here)
+{
+ routerinfo_t *r = router_get_by_digest(id_digest);
+ connection_or_set_identity_digest(conn, id_digest);
+ connection_or_set_rate_burst(conn, get_options());
conn->_base.port = port;
tor_addr_copy(&conn->_base.addr, addr);
--
1.7.1
More information about the tor-commits
mailing list