diff options
author | Nick Mathewson <nickm@torproject.org> | 2010-08-18 15:55:49 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2010-08-18 15:55:49 -0400 |
commit | ba9c1275c4b2325aed6a2fe2cc236794dab11052 (patch) | |
tree | 27be4318e4d65bff4e312a5476bcc184d69aa6cf /src/or/onion.c | |
parent | d72edc4b78f0104823d156e605259d9d41e6f54c (diff) | |
download | tor-ba9c1275c4b2325aed6a2fe2cc236794dab11052.tar.gz tor-ba9c1275c4b2325aed6a2fe2cc236794dab11052.zip |
Add a generic rate-limited log mechanism, and use it in a few places
Incidentally fixes bug 1042.
Diffstat (limited to 'src/or/onion.c')
-rw-r--r-- | src/or/onion.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/or/onion.c b/src/or/onion.c index ebc3583648..fa001656e6 100644 --- a/src/or/onion.c +++ b/src/or/onion.c @@ -63,15 +63,16 @@ onion_pending_add(or_circuit_t *circ, char *onionskin) if (ol_length >= get_options()->MaxOnionsPending) { #define WARN_TOO_MANY_CIRC_CREATIONS_INTERVAL (60) - static time_t last_warned = 0; - time_t now = time(NULL); - if (last_warned + WARN_TOO_MANY_CIRC_CREATIONS_INTERVAL < now) { + static ratelim_t last_warned = + RATELIM_INIT(WARN_TOO_MANY_CIRC_CREATIONS_INTERVAL); + char *m; + if ((m = rate_limit_log(&last_warned, approx_time()))) { log_warn(LD_GENERAL, "Your computer is too slow to handle this many circuit " "creation requests! Please consider using the " "MaxAdvertisedBandwidth config option or choosing a more " - "restricted exit policy."); - last_warned = now; + "restricted exit policy.%s",m); + tor_free(m); } tor_free(tmp); return -1; |