]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Rate-limit v2 networkstatus download fail warnings
authorNick Mathewson <nickm@torproject.org>
Fri, 29 Apr 2011 01:25:24 +0000 (21:25 -0400)
committerNick Mathewson <nickm@torproject.org>
Fri, 29 Apr 2011 01:25:24 +0000 (21:25 -0400)
This fixes part of 1352.  We don't care deeply about these warnings,
since v2 networkstatuses aren't a big deal.

changes/bug1352 [new file with mode: 0644]
src/or/directory.c

diff --git a/changes/bug1352 b/changes/bug1352
new file mode 100644 (file)
index 0000000..bde0192
--- /dev/null
@@ -0,0 +1,4 @@
+  o Minor features
+    - Rate-limit a warning about failures to download v2 networkstatus
+      documents.  Resolves part of bug 1352.
+
index 2ac78111d770c2555d4ef48d3ffa4d498c83d0cc..972dec5bea9708d2cc61741c67e6163610e9bb36 100644 (file)
@@ -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;