summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Hogan <robert@roberthogan.net>2010-08-31 20:45:44 +0100
committerRobert Hogan <robert@roberthogan.net>2010-09-02 22:17:27 +0100
commit2086588efe9c7b378e3813f427d72eb2d135d661 (patch)
treea7fccc998a1f53b444a754ea811bf5659a1086f8
parentd6744d611f933e77398ed80ac45cabfec16430c1 (diff)
downloadtor-2086588efe9c7b378e3813f427d72eb2d135d661.tar.gz
tor-2086588efe9c7b378e3813f427d72eb2d135d661.zip
Amend per Sebastian's comments:
- 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.
-rw-r--r--src/or/directory.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/or/directory.c b/src/or/directory.c
index 11dce8ca71..6364136372 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,