[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] [tor/master] fetch unknown descriptors if we see them in a vote



Author: Roger Dingledine <arma@xxxxxxxxxxxxxx>
Date: Tue, 20 Apr 2010 03:03:33 -0400
Subject: fetch unknown descriptors if we see them in a vote
Commit: 2e692bd8c98c841adf4ae568ad5a7d87f7de2319

---
 src/or/dirvote.c    |    3 +++
 src/or/or.h         |    2 ++
 src/or/routerlist.c |   12 ++++++------
 3 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/src/or/dirvote.c b/src/or/dirvote.c
index 6aa3459..6053e50 100644
--- a/src/or/dirvote.c
+++ b/src/or/dirvote.c
@@ -2685,6 +2685,9 @@ dirvote_add_vote(const char *vote_body, const char **msg_out, int *status_out)
     goto err;
   }
 
+  /* Fetch any new router descriptors we just learned about */
+  update_consensus_router_descriptor_downloads(time(NULL), 1, vote);
+
   /* Now see whether we already have a vote from this authority. */
   SMARTLIST_FOREACH(pending_vote_list, pending_vote_t *, v, {
       if (! memcmp(v->vote->cert->cache_info.identity_digest,
diff --git a/src/or/or.h b/src/or/or.h
index a205b77..e365f69 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -5086,6 +5086,8 @@ trusted_dir_server_t *add_trusted_dir_server(const char *nickname,
 void authority_cert_free(authority_cert_t *cert);
 void clear_trusted_dir_servers(void);
 int any_trusted_dir_is_v1_authority(void);
+void update_consensus_router_descriptor_downloads(time_t now, int is_vote,
+                                                  networkstatus_t *consensus);
 void update_router_descriptor_downloads(time_t now);
 void update_extrainfo_downloads(time_t now);
 int router_have_minimum_dir_info(void);
diff --git a/src/or/routerlist.c b/src/or/routerlist.c
index ca932e6..78af1b8 100644
--- a/src/or/routerlist.c
+++ b/src/or/routerlist.c
@@ -27,8 +27,6 @@ static int router_nickname_matches(routerinfo_t *router, const char *nickname);
 static void trusted_dir_server_free(trusted_dir_server_t *ds);
 static void launch_router_descriptor_downloads(smartlist_t *downloadable,
                                                time_t now);
-static void update_consensus_router_descriptor_downloads(time_t now,
-                                                  networkstatus_t *consensus);
 static int signed_desc_digest_is_recognized(signed_descriptor_t *desc);
 static void update_router_have_minimum_dir_info(void);
 static const char *signed_descriptor_get_body_impl(signed_descriptor_t *desc,
@@ -4332,8 +4330,8 @@ update_router_descriptor_cache_downloads_v2(time_t now)
 
 /** For any descriptor that we want that's currently listed in
  * <b>consensus</b>, download it as appropriate. */
-static void
-update_consensus_router_descriptor_downloads(time_t now,
+void
+update_consensus_router_descriptor_downloads(time_t now, int is_vote,
                                              networkstatus_t *consensus)
 {
   or_options_t *options = get_options();
@@ -4351,8 +4349,10 @@ update_consensus_router_descriptor_downloads(time_t now,
 
   map = digestmap_new();
   list_pending_descriptor_downloads(map, 0);
-  SMARTLIST_FOREACH(consensus->routerstatus_list, routerstatus_t *, rs,
+  SMARTLIST_FOREACH(consensus->routerstatus_list, void *, rsp,
     {
+      routerstatus_t *rs =
+        is_vote ? &(((vote_routerstatus_t *)rsp)->status) : rsp;
       signed_descriptor_t *sd;
       if ((sd = router_get_by_descriptor_digest(rs->descriptor_digest))) {
         routerinfo_t *ri;
@@ -4445,7 +4445,7 @@ update_router_descriptor_downloads(time_t now)
   if (directory_fetches_dir_info_early(options)) {
     update_router_descriptor_cache_downloads_v2(now);
   }
-  update_consensus_router_descriptor_downloads(now,
+  update_consensus_router_descriptor_downloads(now, 0,
     networkstatus_get_reasonably_live_consensus(now));
 
   /* XXXX021 we could be smarter here; see notes on bug 652. */
-- 
1.6.5