mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
Log even less verbosely. Also, do not download old (frequently-updating) servers more than once every 2 hours.
svn:r5134
This commit is contained in:
@@ -169,7 +169,7 @@ N . Routerdesc download changes
|
||||
- Should directory mirrors do something else entirely?
|
||||
- Use has_fetched_directory sanely, whatever that means.
|
||||
- What *does* that mean?
|
||||
- If we have a routerdesc for Bob, and he says, "I'm 0.1.0.x", don't
|
||||
o If we have a routerdesc for Bob, and he says, "I'm 0.1.0.x", don't
|
||||
fetch a new one if it was published in the last 2 hours.
|
||||
- How does this interact with the 'recognized hash' rule?
|
||||
. Downgrade new directory events from notice to info
|
||||
|
||||
+7
-5
@@ -981,7 +981,9 @@ connection_dir_client_reached_eof(connection_t *conn)
|
||||
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.",
|
||||
/* 404 means that it didn't have them; no big deal. */
|
||||
log_fn(status_code == 404 ? LOG_INFO : 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);
|
||||
@@ -1283,7 +1285,7 @@ directory_handle_command_get(connection_t *conn, char *headers,
|
||||
dirserv_get_routerdescs(descs, url);
|
||||
tor_free(url);
|
||||
if (!smartlist_len(descs)) {
|
||||
write_http_status_line(conn, 400, "Servers unavailable.");
|
||||
write_http_status_line(conn, 404, "Servers unavailable.");
|
||||
} else {
|
||||
size_t len = 0;
|
||||
format_rfc1123_time(date, time(NULL));
|
||||
@@ -1588,13 +1590,13 @@ dir_routerdesc_download_failed(smartlist_t *failed)
|
||||
}
|
||||
}
|
||||
if (rs->next_attempt_at == 0)
|
||||
log_fn(LOG_NOTICE, "%s failed %d time(s); I'll try again immediately.",
|
||||
log_fn(LOG_INFO, "%s failed %d time(s); I'll try again immediately.",
|
||||
cp, (int)rs->n_download_failures);
|
||||
else if (rs->next_attempt_at < TIME_MAX)
|
||||
log_fn(LOG_NOTICE, "%s failed %d time(s); I'll try again in %d seconds.",
|
||||
log_fn(LOG_INFO, "%s failed %d time(s); I'll try again in %d seconds.",
|
||||
cp, (int)rs->n_download_failures, (int)(rs->next_attempt_at-now));
|
||||
else
|
||||
log_fn(LOG_NOTICE, "%s failed %d time(s); Giving up for a while.",
|
||||
log_fn(LOG_INFO, "%s failed %d time(s); Giving up for a while.",
|
||||
cp, (int)rs->n_download_failures);
|
||||
});
|
||||
|
||||
|
||||
+16
-4
@@ -2349,7 +2349,9 @@ routers_update_status_from_networkstatus(smartlist_t *routers, int reset_failure
|
||||
static smartlist_t *
|
||||
router_list_downloadable(void)
|
||||
{
|
||||
#define MAX_OLD_SERVER_DOWNLOAD_RATE 2*60*60
|
||||
int n_conns, i, n_downloadable = 0;
|
||||
int n_uptodate=0,n_skip_old=0;
|
||||
connection_t **carray;
|
||||
smartlist_t *superseded = smartlist_create();
|
||||
smartlist_t *downloading;
|
||||
@@ -2424,12 +2426,22 @@ router_list_downloadable(void)
|
||||
continue;
|
||||
}
|
||||
/* Change this "or" to be an "and" once dirs generate hashes right.
|
||||
* Remove the version check once older versions are uncommon.
|
||||
* XXXXX. NM */
|
||||
if (!memcmp(ri->signed_descriptor_digest, rs->status.descriptor_digest,
|
||||
DIGEST_LEN) ||
|
||||
rs->status.published_on <= ri->published_on) {
|
||||
/* Same digest, or earlier. No need to download it. */
|
||||
++n_uptodate;
|
||||
rs->should_download = 0;
|
||||
--n_downloadable;
|
||||
} else if (ri->platform &&
|
||||
!tor_version_as_new_as(ri->platform, "0.1.1.6-alpha") &&
|
||||
ri->published_on + MAX_OLD_SERVER_DOWNLOAD_RATE > now) {
|
||||
/* Same digest, or date is up-to-date, or we have a comparatively recent
|
||||
* server with an old version.
|
||||
* No need to download it. */
|
||||
// log_fn(LOG_NOTICE, "Up-to-date status for %s", fp);
|
||||
++n_skip_old;
|
||||
rs->should_download = 0;
|
||||
--n_downloadable;
|
||||
} /* else {
|
||||
@@ -2447,6 +2459,9 @@ router_list_downloadable(void)
|
||||
});
|
||||
}
|
||||
|
||||
if (n_skip_old)
|
||||
log_fn(LOG_INFO, "Skipped %d updatable pre-0.1.1.6 servers.", n_skip_old);
|
||||
|
||||
if (!n_downloadable)
|
||||
return superseded;
|
||||
|
||||
@@ -2479,7 +2494,6 @@ update_router_descriptor_downloads(time_t now)
|
||||
smartlist_t *downloadable = NULL;
|
||||
int get_all = 0;
|
||||
int always_split = !server_mode(get_options()) || !get_options()->DirPort;
|
||||
|
||||
if (!networkstatus_list || smartlist_len(networkstatus_list)<2)
|
||||
get_all = 1;
|
||||
|
||||
@@ -2519,8 +2533,6 @@ update_router_descriptor_downloads(time_t now)
|
||||
directory_get_from_dirserver(DIR_PURPOSE_FETCH_SERVERDESC,resource,1);
|
||||
}
|
||||
tor_free(resource);
|
||||
} else {
|
||||
log_fn(LOG_NOTICE, "No routers to download.");
|
||||
}
|
||||
SMARTLIST_FOREACH(downloadable, char *, c, tor_free(c));
|
||||
smartlist_free(downloadable);
|
||||
|
||||
Reference in New Issue
Block a user