[or-cvs] r11816: Make authority_certs_fetch_missing only fetch certificates w (in tor/trunk: . src/or)

nickm at seul.org nickm at seul.org
Tue Oct 9 20:44:45 UTC 2007


Author: nickm
Date: 2007-10-09 16:44:45 -0400 (Tue, 09 Oct 2007)
New Revision: 11816

Modified:
   tor/trunk/
   tor/trunk/src/or/networkstatus.c
   tor/trunk/src/or/routerlist.c
Log:
 r15597 at 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



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r15597] on 8246c3cf-6607-4228-993b-4d95d33730f1

Modified: tor/trunk/src/or/networkstatus.c
===================================================================
--- tor/trunk/src/or/networkstatus.c	2007-10-09 20:10:44 UTC (rev 11815)
+++ tor/trunk/src/or/networkstatus.c	2007-10-09 20:44:45 UTC (rev 11816)
@@ -978,10 +978,7 @@
                        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 @@
   }
 
   /* 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)

Modified: tor/trunk/src/or/routerlist.c
===================================================================
--- tor/trunk/src/or/routerlist.c	2007-10-09 20:10:44 UTC (rev 11815)
+++ tor/trunk/src/or/routerlist.c	2007-10-09 20:44:45 UTC (rev 11816)
@@ -37,6 +37,8 @@
 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 @@
 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 @@
         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 @@
     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 @@
   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 @@
   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 @@
   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,



More information about the tor-commits mailing list