summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2016-07-26 09:59:48 -0400
committerNick Mathewson <nickm@torproject.org>2016-07-26 09:59:48 -0400
commitfb7f90c181dc44ae9f23cb4d16cac25609463d9f (patch)
tree8dbd4fcac2b2a70c3089858efc219d3bd5b8879c
parent77459b97aac15949c5160ca8abb9af792f02ac73 (diff)
downloadtor-fb7f90c181dc44ae9f23cb4d16cac25609463d9f.tar.gz
tor-fb7f90c181dc44ae9f23cb4d16cac25609463d9f.zip
Tweaks on 19435 fix:
* Raise limit: 16k isn't all that high. * Don't log when limit exceded; log later on. * Say "over" when we log more than we say we log. * Add target version to changes file
-rw-r--r--changes/bug194354
-rw-r--r--src/common/util.c12
-rw-r--r--src/common/util.h2
3 files changed, 7 insertions, 11 deletions
diff --git a/changes/bug19435 b/changes/bug19435
index ccd916be0f..d0a29d1983 100644
--- a/changes/bug19435
+++ b/changes/bug19435
@@ -2,5 +2,5 @@
- Fix an integer overflow in the rate-limiter that caused displaying of
wrong number of suppressed messages (if there are too many of them).
If the number of messages hits the limit of messages per interval the
- rate-limiter drops a warning and doesn't count any further.
- Fixes bug 19435.
+ rate-limiter doesn't count any further.
+ Fixes bug 19435; bugfix on 0.2.4.11-alpha.
diff --git a/src/common/util.c b/src/common/util.c
index 72efd897a7..d9361563ef 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -1995,12 +1995,7 @@ rate_limit_is_ready(ratelim_t *lim, time_t now)
lim->n_calls_since_last_time = 0;
return res;
} else {
- if (lim->n_calls_since_last_time < RATELIM_TOOMANY) {
- ++lim->n_calls_since_last_time;
- } else if (lim->n_calls_since_last_time == RATELIM_TOOMANY) {
- log_warn(LD_GENERAL,
- "Enormously large number of messages (%d). It's probably a bug.",
- RATELIM_TOOMANY);
+ if (lim->n_calls_since_last_time <= RATELIM_TOOMANY) {
++lim->n_calls_since_last_time;
}
@@ -2020,11 +2015,12 @@ rate_limit_log(ratelim_t *lim, time_t now)
return tor_strdup("");
} else {
char *cp=NULL;
+ const char *opt_over = (n >= RATELIM_TOOMANY) ? "over " : "";
/* XXXX this is not exactly correct: the messages could have occurred
* any time between the old value of lim->allowed and now. */
tor_asprintf(&cp,
- " [%d similar message(s) suppressed in last %d seconds]",
- n-1, lim->rate);
+ " [%s%d similar message(s) suppressed in last %d seconds]",
+ opt_over, n-1, lim->rate);
return cp;
}
} else {
diff --git a/src/common/util.h b/src/common/util.h
index 837d2e9cf3..a6638aa39b 100644
--- a/src/common/util.h
+++ b/src/common/util.h
@@ -292,7 +292,7 @@ typedef struct ratelim_t {
} ratelim_t;
#define RATELIM_INIT(r) { (r), 0, 0 }
-#define RATELIM_TOOMANY (16*1000)
+#define RATELIM_TOOMANY (16*1000*1000)
char *rate_limit_log(ratelim_t *lim, time_t now);