[tor-commits] [tor/release-0.2.2] Rate-limit v2 networkstatus download fail warnings

arma at torproject.org arma at torproject.org
Sat May 14 03:38:38 UTC 2011


commit bcdffc0f80c0d5c9ed8c3858d95f351e14f9c722
Author: Nick Mathewson <nickm at torproject.org>
Date:   Thu Apr 28 21:25:24 2011 -0400

    Rate-limit v2 networkstatus download fail warnings
    
    This fixes part of 1352.  We don't care deeply about these warnings,
    since v2 networkstatuses aren't a big deal.
---
 changes/bug1352    |    4 ++++
 src/or/directory.c |   16 +++++++++++-----
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/changes/bug1352 b/changes/bug1352
new file mode 100644
index 0000000..bde0192
--- /dev/null
+++ b/changes/bug1352
@@ -0,0 +1,4 @@
+  o Minor features
+    - Rate-limit a warning about failures to download v2 networkstatus
+      documents.  Resolves part of bug 1352.
+
diff --git a/src/or/directory.c b/src/or/directory.c
index 2ac7811..972dec5 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -1647,11 +1647,17 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
     log_info(LD_DIR,"Received networkstatus objects (size %d) from server "
              "'%s:%d'", (int)body_len, conn->_base.address, conn->_base.port);
     if (status_code != 200) {
-      log_warn(LD_DIR,
-           "Received http status code %d (%s) from server "
-           "'%s:%d' while fetching \"/tor/status/%s\". I'll try again soon.",
-           status_code, escaped(reason), conn->_base.address,
-           conn->_base.port, conn->requested_resource);
+      static ratelim_t warning_limit = RATELIM_INIT(3600);
+      char *m;
+      if ((m = rate_limit_log(&warning_limit, now))) {
+        log_warn(LD_DIR,
+                 "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);
       connection_dir_download_v2_networkstatus_failed(conn, status_code);
       return -1;





More information about the tor-commits mailing list