summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2005-09-23 21:25:29 +0000
committerNick Mathewson <nickm@torproject.org>2005-09-23 21:25:29 +0000
commitb726507d367bbc46b9cefcb26afe32cd2cd12833 (patch)
tree691a22732dc67013d3a4d591f3ac3afe6c5b185d /src
parent31c7f59b25c47293f2aac345ddabe9bcd4af6d96 (diff)
downloadtor-b726507d367bbc46b9cefcb26afe32cd2cd12833.tar.gz
tor-b726507d367bbc46b9cefcb26afe32cd2cd12833.zip
Log even less verbosely. Also, do not download old (frequently-updating) servers more than once every 2 hours.
svn:r5134
Diffstat (limited to 'src')
-rw-r--r--src/or/directory.c12
-rw-r--r--src/or/routerlist.c20
2 files changed, 23 insertions, 9 deletions
diff --git a/src/or/directory.c b/src/or/directory.c
index cec7e964f0..0e5da0bf4c 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -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);
});
diff --git a/src/or/routerlist.c b/src/or/routerlist.c
index 05c3bc4c13..51792e9289 100644
--- a/src/or/routerlist.c
+++ b/src/or/routerlist.c
@@ -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);