diff options
author | Nick Mathewson <nickm@torproject.org> | 2007-07-29 05:32:03 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2007-07-29 05:32:03 +0000 |
commit | 9031bbd4d86b4222af8e487a2f8204c334e410a5 (patch) | |
tree | 7aa262546352c1f9014443b16a073c881fe93826 /src | |
parent | 1b665b3c7e13b493e229bf308bf4de7a1d7413c3 (diff) | |
download | tor-9031bbd4d86b4222af8e487a2f8204c334e410a5.tar tor-9031bbd4d86b4222af8e487a2f8204c334e410a5.tar.gz |
r13982@catbus: nickm | 2007-07-29 01:31:53 -0400
Actually, we missed a rule about what routers to prefer: first prefer authority to non-authority, *then* running, *then* bandwidth.
svn:r10969
Diffstat (limited to 'src')
-rw-r--r-- | src/or/dirserv.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/or/dirserv.c b/src/or/dirserv.c index 0a7a5f01a..bf818d01e 100644 --- a/src/or/dirserv.c +++ b/src/or/dirserv.c @@ -1727,16 +1727,30 @@ static int _compare_routerinfo_by_ip_and_bw(const void **a, const void **b) { routerinfo_t *first = *(routerinfo_t **)a, *second = *(routerinfo_t **)b; + int first_is_auth, second_is_auth; + /* we return -1 if first should appear before second... that is, * if first is a better router. */ if (first->addr < second->addr) return -1; else if (first->addr > second->addr) return 1; + + first_is_auth = + router_digest_is_trusted_dir(first->cache_info.identity_digest); + second_is_auth = + router_digest_is_trusted_dir(second->cache_info.identity_digest); + + if (first_is_auth && !second_is_auth) + return -1; + else if (!first_is_auth && second_is_auth) + return 1; + else if (first->is_running && !second->is_running) return -1; else if (!first->is_running && second->is_running) return 1; + else if (first->bandwidthrate > second->bandwidthrate) return -1; else if (first->bandwidthrate < second->bandwidthrate) |