Merge branch 'bug1352' into maint-0.2.2

This commit is contained in:
Nick Mathewson 2011-05-12 00:14:10 -04:00
commit b47f574c1e
2 changed files with 19 additions and 9 deletions

4
changes/bug1352 Normal file
View File

@ -0,0 +1,4 @@
o Minor features
- Rate-limit a warning about failures to download v2 networkstatus
documents. Resolves part of bug 1352.

View File

@ -64,7 +64,7 @@ static int purpose_needs_anonymity(uint8_t dir_purpose,
uint8_t router_purpose); uint8_t router_purpose);
static char *http_get_header(const char *headers, const char *which); static char *http_get_header(const char *headers, const char *which);
static void http_set_address_origin(const char *headers, connection_t *conn); static void http_set_address_origin(const char *headers, connection_t *conn);
static void connection_dir_download_networkstatus_failed( static void connection_dir_download_v2_networkstatus_failed(
dir_connection_t *conn, int status_code); dir_connection_t *conn, int status_code);
static void connection_dir_download_routerdesc_failed(dir_connection_t *conn); 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_bridge_routerdesc_failed(dir_connection_t *conn);
@ -617,7 +617,7 @@ connection_dir_request_failed(dir_connection_t *conn)
if (conn->_base.purpose == DIR_PURPOSE_FETCH_V2_NETWORKSTATUS) { if (conn->_base.purpose == DIR_PURPOSE_FETCH_V2_NETWORKSTATUS) {
log_info(LD_DIR, "Giving up on directory server at '%s'; retrying", log_info(LD_DIR, "Giving up on directory server at '%s'; retrying",
conn->_base.address); conn->_base.address);
connection_dir_download_networkstatus_failed(conn, -1); connection_dir_download_v2_networkstatus_failed(conn, -1);
} else if (conn->_base.purpose == DIR_PURPOSE_FETCH_SERVERDESC || } else if (conn->_base.purpose == DIR_PURPOSE_FETCH_SERVERDESC ||
conn->_base.purpose == DIR_PURPOSE_FETCH_EXTRAINFO) { conn->_base.purpose == DIR_PURPOSE_FETCH_EXTRAINFO) {
log_info(LD_DIR, "Giving up on directory server at '%s'; retrying", log_info(LD_DIR, "Giving up on directory server at '%s'; retrying",
@ -645,7 +645,7 @@ connection_dir_request_failed(dir_connection_t *conn)
* retry the fetch now, later, or never. * retry the fetch now, later, or never.
*/ */
static void static void
connection_dir_download_networkstatus_failed(dir_connection_t *conn, connection_dir_download_v2_networkstatus_failed(dir_connection_t *conn,
int status_code) int status_code)
{ {
if (!conn->requested_resource) { if (!conn->requested_resource) {
@ -1648,13 +1648,19 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
log_info(LD_DIR,"Received networkstatus objects (size %d) from server " log_info(LD_DIR,"Received networkstatus objects (size %d) from server "
"'%s:%d'", (int)body_len, conn->_base.address, conn->_base.port); "'%s:%d'", (int)body_len, conn->_base.address, conn->_base.port);
if (status_code != 200) { if (status_code != 200) {
log_warn(LD_DIR, static ratelim_t warning_limit = RATELIM_INIT(3600);
"Received http status code %d (%s) from server " char *m;
"'%s:%d' while fetching \"/tor/status/%s\". I'll try again soon.", if ((m = rate_limit_log(&warning_limit, now))) {
status_code, escaped(reason), conn->_base.address, log_warn(LD_DIR,
conn->_base.port, conn->requested_resource); "Received http status code %d (%s) from server "
"'%s:%d' while fetching \"/tor/status/%s\". "
"I'll try again soon.%s",
status_code, escaped(reason), conn->_base.address,
conn->_base.port, conn->requested_resource, m);
tor_free(m);
}
tor_free(body); tor_free(headers); tor_free(reason); tor_free(body); tor_free(headers); tor_free(reason);
connection_dir_download_networkstatus_failed(conn, status_code); connection_dir_download_v2_networkstatus_failed(conn, status_code);
return -1; return -1;
} }
if (conn->requested_resource && if (conn->requested_resource &&