aboutsummaryrefslogtreecommitdiff
path: root/src/or/circuitbuild.c
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2008-02-12 22:02:47 +0000
committerRoger Dingledine <arma@torproject.org>2008-02-12 22:02:47 +0000
commit3abafccd0eadb267401f20ef8c816c6e7f1c693e (patch)
tree7d0a5e4c28f40d1d4aaa410a401b61f4c83d7424 /src/or/circuitbuild.c
parentd3331b3c125697bc9f1bbd8ca1917a0702770acc (diff)
downloadtor-3abafccd0eadb267401f20ef8c816c6e7f1c693e.tar.gz
tor-3abafccd0eadb267401f20ef8c816c6e7f1c693e.zip
Start choosing which bridge to use proportional to its advertised
bandwidth, rather than uniformly at random. This should speed up Tor for bridge users. Also do this for people who set StrictEntryNodes. svn:r13486
Diffstat (limited to 'src/or/circuitbuild.c')
-rw-r--r--src/or/circuitbuild.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index bd6f504c3b..c639b843ff 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -2501,7 +2501,16 @@ choose_random_entry(cpath_build_state_t *state)
}
choose_and_finish:
- r = smartlist_choose(live_entry_guards);
+ if (entry_list_can_grow(options)) {
+ /* We choose uniformly at random here, because choose_good_entry_server()
+ * already weights its choices by bandwidth, so we don't want to
+ * *double*-weight our guard selection. */
+ r = smartlist_choose(live_entry_guards);
+ } else {
+ /* We need to weight by bandwidth, because our bridges or entryguards
+ * were not already selected proportional to their bandwidth. */
+ r = routerlist_sl_choose_by_bandwidth(live_entry_guards, WEIGHT_FOR_GUARD);
+ }
smartlist_free(live_entry_guards);
smartlist_free(exit_family);
return r;