aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2007-10-09 20:44:45 +0000
committerNick Mathewson <nickm@torproject.org>2007-10-09 20:44:45 +0000
commit010fd50c365f90f98e9e8ec243a573aba4c53cfa (patch)
treeaf687a50962de9387395b9ae1fa8e06520759e9e /src
parent0827d6f217797b2b70834e85cf8d05d8c72dc28a (diff)
downloadtor-010fd50c365f90f98e9e8ec243a573aba4c53cfa.tar
tor-010fd50c365f90f98e9e8ec243a573aba4c53cfa.tar.gz
r15597@catbus: nickm | 2007-10-09 16:17:42 -0400
Make authority_certs_fetch_missing only fetch certificates which we are not currently downloading; fix XXXX020s in networkstatus.c svn:r11816
Diffstat (limited to 'src')
-rw-r--r--src/or/networkstatus.c11
-rw-r--r--src/or/routerlist.c38
2 files changed, 30 insertions, 19 deletions
diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c
index b65d43446..8026b5ff1 100644
--- a/src/or/networkstatus.c
+++ b/src/or/networkstatus.c
@@ -978,10 +978,7 @@ networkstatus_set_current_consensus(const char *consensus, int from_cache,
options->DataDirectory);
write_str_to_file(filename, consensus, 0);
}
- /* XXXX this test isn't quite right; see below. */
- if (!connection_get_by_type_purpose(CONN_TYPE_DIR,
- DIR_PURPOSE_FETCH_CERTIFICATE))
- authority_certs_fetch_missing(c);
+ authority_certs_fetch_missing(c);
}
return 0;
} else {
@@ -994,11 +991,7 @@ networkstatus_set_current_consensus(const char *consensus, int from_cache,
}
/* Are we missing any certificates at all? */
- /* XXXX The test for 'are we downloading' should be 'are we downloading
- * these certificates', and it should get pushed into
- * authority_certs_fetch_missing. */
- if (r != 1 && !connection_get_by_type_purpose(CONN_TYPE_DIR,
- DIR_PURPOSE_FETCH_CERTIFICATE))
+ if (r != 1)
authority_certs_fetch_missing(c);
if (current_consensus)
diff --git a/src/or/routerlist.c b/src/or/routerlist.c
index 36cd20fcc..cf654aeaf 100644
--- a/src/or/routerlist.c
+++ b/src/or/routerlist.c
@@ -37,6 +37,8 @@ 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,
int with_annotations);
+static void list_pending_downloads(digestmap_t *result,
+ int purpose, const char *prefix);
DECLARE_TYPED_DIGESTMAP_FNS(sdmap_, digest_sd_map_t, signed_descriptor_t)
DECLARE_TYPED_DIGESTMAP_FNS(rimap_, digest_ri_map_t, routerinfo_t)
@@ -286,8 +288,12 @@ authority_cert_get_by_digests(const char *id_digest,
void
authority_certs_fetch_missing(networkstatus_vote_t *status)
{
+ digestmap_t *pending = digestmap_new();
smartlist_t *missing_digests = smartlist_create();
char *resource;
+ time_t now = time(NULL);
+
+ list_pending_downloads(pending, DIR_PURPOSE_FETCH_CERTIFICATE, "fp/");
if (status) {
SMARTLIST_FOREACH(status->voters, networkstatus_voter_info_t *, voter,
{
@@ -308,7 +314,8 @@ authority_certs_fetch_missing(networkstatus_vote_t *status)
continue;
SMARTLIST_FOREACH(ds->v3_certs, authority_cert_t *, cert,
{
- if (1) { //XXXX020! cert_is_definitely_expired(cert, now)) {
+ if (ftime_definitely_before(cert->expires, now)) {
+ /* It's definitely expired. */
found = 1;
break;
}
@@ -320,7 +327,10 @@ authority_certs_fetch_missing(networkstatus_vote_t *status)
smartlist_t *fps = smartlist_create();
smartlist_add(fps, tor_strdup("fp/"));
SMARTLIST_FOREACH(missing_digests, const char *, d, {
- char *fp = tor_malloc(HEX_DIGEST_LEN+2);
+ char *fp;
+ if (digestmap_get(pending, d))
+ continue;
+ fp = tor_malloc(HEX_DIGEST_LEN+2);
base16_encode(fp, HEX_DIGEST_LEN+1, d, DIGEST_LEN);
fp[HEX_DIGEST_LEN] = '+';
fp[HEX_DIGEST_LEN+1] = '\0';
@@ -337,6 +347,7 @@ authority_certs_fetch_missing(networkstatus_vote_t *status)
directory_get_from_dirserver(DIR_PURPOSE_FETCH_CERTIFICATE, 0,
resource, 1);
tor_free(resource);
+ digestmap_free(pending, NULL);
}
/* Router descriptor storage.
@@ -3349,17 +3360,13 @@ compute_recommended_versions(time_t now, int client,
return result;
}
-/** For every router descriptor (or extra-info document if <b>extrainfo</b> is
- * true) we are currently downloading by descriptor digest, set result[d] to
- * (void*)1. */
+/** DOCDOC */
static void
-list_pending_descriptor_downloads(digestmap_t *result, int extrainfo)
+list_pending_downloads(digestmap_t *result,
+ int purpose, const char *prefix)
{
- const char *prefix = "d/";
- size_t p_len = strlen(prefix);
+ const size_t p_len = strlen(prefix);
smartlist_t *tmp = smartlist_create();
- int purpose =
- extrainfo ? DIR_PURPOSE_FETCH_EXTRAINFO : DIR_PURPOSE_FETCH_SERVERDESC;
smartlist_t *conns = get_connection_array();
tor_assert(result);
@@ -3383,6 +3390,17 @@ list_pending_descriptor_downloads(digestmap_t *result, int extrainfo)
smartlist_free(tmp);
}
+/** For every router descriptor (or extra-info document if <b>extrainfo</b> is
+ * true) we are currently downloading by descriptor digest, set result[d] to
+ * (void*)1. */
+static void
+list_pending_descriptor_downloads(digestmap_t *result, int extrainfo)
+{
+ int purpose =
+ extrainfo ? DIR_PURPOSE_FETCH_EXTRAINFO : DIR_PURPOSE_FETCH_SERVERDESC;
+ list_pending_downloads(result, purpose, "d/");
+}
+
/** Launch downloads for all the descriptors whose digests are listed
* as digests[i] for lo <= i < hi. (Lo and hi may be out of range.)
* If <b>source</b> is given, download from <b>source</b>; otherwise,