|
@@ -790,7 +790,6 @@ router_get_consensus_status_by_nickname(const char *nickname,
|
|
|
routerstatus_t *best=NULL;
|
|
|
smartlist_t *matches=NULL;
|
|
|
const char *named_id=NULL;
|
|
|
- int any_unnamed=0;
|
|
|
|
|
|
if (!current_consensus || !nickname)
|
|
|
return NULL;
|
|
@@ -820,22 +819,23 @@ router_get_consensus_status_by_nickname(const char *nickname,
|
|
|
{
|
|
|
if (!strcasecmp(lrs->nickname, nickname)) {
|
|
|
if (lrs->is_named) {
|
|
|
-
|
|
|
+ tor_fragile_assert()
|
|
|
smartlist_free(matches);
|
|
|
return lrs;
|
|
|
} else {
|
|
|
- if (lrs->is_unnamed)
|
|
|
- smartlist_free(matches);
|
|
|
+ if (lrs->is_unnamed) {
|
|
|
+ tor_fragile_assert();
|
|
|
+ smartlist_clear(matches);
|
|
|
+ best=NULL;
|
|
|
+ break;
|
|
|
+ }
|
|
|
smartlist_add(matches, lrs);
|
|
|
best = lrs;
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- if (any_unnamed) {
|
|
|
-
|
|
|
- return NULL;
|
|
|
- } else if (smartlist_len(matches)>1 && warn_if_unnamed) {
|
|
|
+ if (smartlist_len(matches)>1 && warn_if_unnamed) {
|
|
|
int any_unwarned=0;
|
|
|
SMARTLIST_FOREACH(matches, routerstatus_t *, lrs,
|
|
|
{
|
|
@@ -949,6 +949,9 @@ update_v2_networkstatus_cache_downloads(time_t now)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+#define CONSENUS_NETWORKSTATUS_MAX_DL_TRIES 8
|
|
|
+
|
|
|
|
|
|
* appropriate. */
|
|
|
static void
|
|
@@ -961,8 +964,8 @@ update_consensus_networkstatus_downloads(time_t now)
|
|
|
return;
|
|
|
if (authdir_mode_v3(options))
|
|
|
return;
|
|
|
-
|
|
|
- if (!download_status_is_ready(&consensus_dl_status, now, 8))
|
|
|
+ if (!download_status_is_ready(&consensus_dl_status, now,
|
|
|
+ CONSENSUS_NETWORKSTATUS_MAX_DL_TRIES))
|
|
|
return;
|
|
|
if (connection_get_by_type_purpose(CONN_TYPE_DIR,
|
|
|
DIR_PURPOSE_FETCH_CONSENSUS))
|
|
@@ -982,6 +985,9 @@ networkstatus_consensus_download_failed(int status_code)
|
|
|
update_consensus_networkstatus_downloads(time(NULL));
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+#define CONSENSUS_MIN_SECONDS_BEFORE_CACHING 120
|
|
|
+
|
|
|
|
|
|
* consensus. */
|
|
|
void
|
|
@@ -994,12 +1000,16 @@ update_consensus_networkstatus_fetch_time(time_t now)
|
|
|
long interval = c->fresh_until - c->valid_after;
|
|
|
time_t start;
|
|
|
if (dirserver_mode(options)) {
|
|
|
- start = c->fresh_until + 120;
|
|
|
+
|
|
|
+ * is no longer fresh... */
|
|
|
+ start = c->fresh_until + CONSENSUS_MIN_SECONDS_BEFORE_CACHING;
|
|
|
+
|
|
|
dl_interval = interval/2;
|
|
|
} else {
|
|
|
+
|
|
|
start = c->fresh_until + (interval*3)/4;
|
|
|
-
|
|
|
- dl_interval = (c->valid_until - start) * 7 / 8;
|
|
|
+
|
|
|
+ dl_interval = ((c->valid_until - start) * 7 )/ 8;
|
|
|
}
|
|
|
if (dl_interval < 1)
|
|
|
dl_interval = 1;
|
|
@@ -1275,14 +1285,16 @@ routers_update_all_from_networkstatus(time_t now)
|
|
|
routerlist_t *rl = router_get_routerlist();
|
|
|
networkstatus_vote_t *consensus = networkstatus_get_live_consensus(now);
|
|
|
|
|
|
- router_dir_info_changed();
|
|
|
-
|
|
|
if (networkstatus_v2_list_has_changed)
|
|
|
download_status_map_update_from_v2_networkstatus();
|
|
|
|
|
|
if (!consensus)
|
|
|
return;
|
|
|
|
|
|
+
|
|
|
+ * enough directory info. */
|
|
|
+ router_dir_info_changed();
|
|
|
+
|
|
|
routers_update_status_from_consensus_networkstatus(rl->routers, 0);
|
|
|
SMARTLIST_FOREACH(rl->routers, routerinfo_t *, ri,
|
|
|
ri->routerlist_index = ri_sl_idx);
|