diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/or/circuitbuild.c | 11 | ||||
-rw-r--r-- | src/or/routerlist.c | 1 |
2 files changed, 11 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; diff --git a/src/or/routerlist.c b/src/or/routerlist.c index 46a372c1e7..d1b0e820ed 100644 --- a/src/or/routerlist.c +++ b/src/or/routerlist.c @@ -1393,6 +1393,7 @@ get_max_believable_bandwidth(void) * If <b>for_guard</b>, we're picking a guard node: consider all guard's * bandwidth equally. Otherwise, weight guards proportionally less. * + * XXX DOCDOC the above args aren't args anymore */ static void * smartlist_choose_by_bandwidth(smartlist_t *sl, bandwidth_weight_rule_t rule, |