Make give-up-on-failure actually work: it seems the servers gave me a real test case.

svn:r5091
This commit is contained in:
Nick Mathewson 2005-09-18 04:15:39 +00:00
parent d118d5069a
commit 283032960d
3 changed files with 26 additions and 15 deletions

View File

@ -973,22 +973,27 @@ connection_dir_client_reached_eof(connection_t *conn)
int n_asked_for = 0; int n_asked_for = 0;
log_fn(LOG_INFO,"Received server info (size %d) from server '%s:%d'", log_fn(LOG_INFO,"Received server info (size %d) from server '%s:%d'",
(int)body_len, conn->address, conn->port); (int)body_len, conn->address, conn->port);
if (status_code != 200) {
log_fn(LOG_WARN,"Received http status code %d (\"%s\") from server '%s:%d' while fetching \"/tor/server/%s\". I'll try again soon.",
status_code, reason, conn->address, conn->port,
conn->requested_resource);
tor_free(body); tor_free(headers); tor_free(reason);
connection_dir_download_routerdesc_failed(conn);
return -1;
}
if (conn->requested_resource && if (conn->requested_resource &&
!strcmpstart(conn->requested_resource,"fp/")) { !strcmpstart(conn->requested_resource,"fp/")) {
which = smartlist_create(); which = smartlist_create();
dir_split_resource_into_fingerprints(conn->requested_resource+3, dir_split_resource_into_fingerprints(conn->requested_resource+3,
which, NULL); which, NULL);
}
if (which)
n_asked_for = smartlist_len(which); n_asked_for = smartlist_len(which);
}
if (status_code != 200) {
log_fn(LOG_WARN,"Received http status code %d (\"%s\") from server '%s:%d' while fetching \"/tor/server/%s\". I'll try again soon.",
status_code, reason, conn->address, conn->port,
conn->requested_resource);
tor_free(body); tor_free(headers); tor_free(reason);
if (!which) {
connection_dir_download_routerdesc_failed(conn);
} else {
dir_routerdesc_download_failed(which);
SMARTLIST_FOREACH(which, char *, cp, tor_free(cp));
smartlist_free(which);
return -1;
}
}
router_load_routers_from_string(body, 0, which); router_load_routers_from_string(body, 0, which);
directory_info_has_arrived(time(NULL),0); directory_info_has_arrived(time(NULL),0);
if (which) { if (which) {
@ -1548,9 +1553,12 @@ dir_networkstatus_download_failed(smartlist_t *failed)
static void static void
dir_routerdesc_download_failed(smartlist_t *failed) dir_routerdesc_download_failed(smartlist_t *failed)
{ {
char digest[DIGEST_LEN];
routerstatus_t *rs;
SMARTLIST_FOREACH(failed, const char *, cp, SMARTLIST_FOREACH(failed, const char *, cp,
{ {
routerstatus_t *rs = router_get_combined_status_by_digest(cp); base16_decode(digest, DIGEST_LEN, cp, strlen(cp));
rs = router_get_combined_status_by_digest(digest);
if (!rs || rs->n_download_failures >= MAX_ROUTERDESC_DOWNLOAD_FAILURES) if (!rs || rs->n_download_failures >= MAX_ROUTERDESC_DOWNLOAD_FAILURES)
continue; continue;
++rs->n_download_failures; ++rs->n_download_failures;

View File

@ -805,8 +805,8 @@ typedef struct routerstatus_t {
* recent descriptor. */ * recent descriptor. */
} routerstatus_t; } routerstatus_t;
/*XXXX001 make this configurable! */ /*XXXX011 make this configurable? */
#define MAX_ROUTERDESC_DOWNLOAD_FAILURES 16 #define MAX_ROUTERDESC_DOWNLOAD_FAILURES 8
/** Contents of a (v2 or later) network status object. */ /** Contents of a (v2 or later) network status object. */
typedef struct networkstatus_t { typedef struct networkstatus_t {

View File

@ -2253,8 +2253,7 @@ router_list_downloadable(void)
continue; continue;
} }
/*XXXX001 reset max_routerdesc_download_failures somewhere! */ /*XXXX001 reset max_routerdesc_download_failures somewhere! */
if (rs->n_download_failures >= MAX_ROUTERDESC_DOWNLOAD_FAILURES || if (!memcmp(ri->signed_descriptor_digest,rs->descriptor_digest,DIGEST_LEN)||
!memcmp(ri->signed_descriptor_digest,rs->descriptor_digest,DIGEST_LEN)||
rs->published_on <= ri->published_on) { rs->published_on <= ri->published_on) {
/* Same digest, or earlier. No need to download it. */ /* Same digest, or earlier. No need to download it. */
// log_fn(LOG_NOTICE, "Up-to-date status for %s", fp); // log_fn(LOG_NOTICE, "Up-to-date status for %s", fp);
@ -2284,7 +2283,11 @@ router_list_downloadable(void)
const char *key; const char *key;
void *val; void *val;
strmap_iter_get(iter, &key, &val); strmap_iter_get(iter, &key, &val);
rs = val;
if (rs->n_download_failures >= MAX_ROUTERDESC_DOWNLOAD_FAILURES)
continue;
smartlist_add(superseded, tor_strdup(key)); smartlist_add(superseded, tor_strdup(key));
log_fn(LOG_NOTICE, "!!!!%d", ((routerstatus_t*)val)->n_download_failures);
} }
strmap_free(status_map, NULL); strmap_free(status_map, NULL);