|
@@ -1727,16 +1727,30 @@ static int
|
|
_compare_routerinfo_by_ip_and_bw(const void **a, const void **b)
|
|
_compare_routerinfo_by_ip_and_bw(const void **a, const void **b)
|
|
{
|
|
{
|
|
routerinfo_t *first = *(routerinfo_t **)a, *second = *(routerinfo_t **)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,
|
|
/* we return -1 if first should appear before second... that is,
|
|
* if first is a better router. */
|
|
* if first is a better router. */
|
|
if (first->addr < second->addr)
|
|
if (first->addr < second->addr)
|
|
return -1;
|
|
return -1;
|
|
else if (first->addr > second->addr)
|
|
else if (first->addr > second->addr)
|
|
return 1;
|
|
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)
|
|
else if (first->is_running && !second->is_running)
|
|
return -1;
|
|
return -1;
|
|
else if (!first->is_running && second->is_running)
|
|
else if (!first->is_running && second->is_running)
|
|
return 1;
|
|
return 1;
|
|
|
|
+
|
|
else if (first->bandwidthrate > second->bandwidthrate)
|
|
else if (first->bandwidthrate > second->bandwidthrate)
|
|
return -1;
|
|
return -1;
|
|
else if (first->bandwidthrate < second->bandwidthrate)
|
|
else if (first->bandwidthrate < second->bandwidthrate)
|