[or-cvs] [tor/master 2/6] Amend per Sebastian's comments:

nickm at torproject.org nickm at torproject.org
Mon Sep 13 01:39:11 UTC 2010


Author: Robert Hogan <robert at roberthogan.net>
Date: Tue, 31 Aug 2010 20:45:44 +0100
Subject: Amend per Sebastian's comments:
Commit: 2086588efe9c7b378e3813f427d72eb2d135d661

 - Move checks for extra_info to callers
 - Change argument name from failed to descs
 - Use strlen("fp/") instead of a magic number
 - I passed on the suggestion to rename functions from *_failed() to
   *_handle_failure(). There are a lot of these so for now just follow
   the house style.
---
 src/or/directory.c |   24 +++++++++++++-----------
 1 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/src/or/directory.c b/src/or/directory.c
index 11dce8c..6364136 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -70,7 +70,7 @@ static void connection_dir_download_routerdesc_failed(dir_connection_t *conn);
 static void connection_dir_bridge_routerdesc_failed(dir_connection_t *conn);
 static void connection_dir_download_cert_failed(
                                dir_connection_t *conn, int status_code);
-static void connection_dir_retry_bridges(smartlist_t* failed, int was_ei);
+static void connection_dir_retry_bridges(smartlist_t* descs);
 static void dir_networkstatus_download_failed(smartlist_t *failed,
                                               int status_code);
 static void dir_routerdesc_download_failed(smartlist_t *failed,
@@ -653,11 +653,10 @@ connection_dir_download_networkstatus_failed(dir_connection_t *conn,
  * listed in <b>failed</b>.
  */
 static void
-connection_dir_retry_bridges(smartlist_t* failed, int was_ei)
+connection_dir_retry_bridges(smartlist_t* descs)
 {
   char digest[DIGEST_LEN];
-  tor_assert(!was_ei); /* not supported yet */
-  SMARTLIST_FOREACH(failed, const char *, cp,
+  SMARTLIST_FOREACH(descs, const char *, cp,
   {
     if (base16_decode(digest, DIGEST_LEN, cp, strlen(cp))<0) {
       log_warn(LD_BUG, "Malformed fingerprint in list: %s",
@@ -692,21 +691,22 @@ connection_dir_download_routerdesc_failed(dir_connection_t *conn)
 static void
 connection_dir_bridge_routerdesc_failed(dir_connection_t *conn)
 {
-  int was_ei;
   smartlist_t *which = NULL;
 
+  tor_assert(conn->requested_resource);
   /* Requests for bridge descriptors are in the form 'fp/', so ignore
      anything else. */
   if (conn->requested_resource && strcmpstart(conn->requested_resource,"fp/"))
     return;
 
   which = smartlist_create();
-  dir_split_resource_into_fingerprints(conn->requested_resource + 3,
-                                        which, NULL, 0);
+  dir_split_resource_into_fingerprints(conn->requested_resource
+                                        + strlen("fp/"),
+                                       which, NULL, 0);
 
-  was_ei =  conn->_base.purpose == DIR_PURPOSE_FETCH_EXTRAINFO;
+  tor_assert(!conn->_base.purpose == DIR_PURPOSE_FETCH_EXTRAINFO);
   if (smartlist_len(which)) {
-    connection_dir_retry_bridges(which, was_ei);
+    connection_dir_retry_bridges(which);
     SMARTLIST_FOREACH(which, char *, cp, tor_free(cp));
   }
   smartlist_free(which);
@@ -3548,8 +3548,10 @@ dir_routerdesc_download_failed(smartlist_t *failed, int status_code,
   time_t now = time(NULL);
   int server = directory_fetches_from_authorities(get_options());
   if (!was_descriptor_digests) {
-    if (router_purpose == ROUTER_PURPOSE_BRIDGE)
-      connection_dir_retry_bridges(failed, was_extrainfo);
+    if (router_purpose == ROUTER_PURPOSE_BRIDGE) {
+      tor_assert(!was_extrainfo);
+      connection_dir_retry_bridges(failed);
+    }
     return; /* FFFF should implement for other-than-router-purpose someday */
   }
   SMARTLIST_FOREACH(failed, const char *, cp,
-- 
1.7.1




More information about the tor-commits mailing list