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/connection.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/connection.c')
-rw-r--r-- | src/or/connection.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/or/connection.c b/src/or/connection.c index c040be041e..91ce74b5b0 100644 --- a/src/or/connection.c +++ b/src/or/connection.c @@ -839,13 +839,13 @@ static void warn_too_many_conns(void) { #define WARN_TOO_MANY_CONNS_INTERVAL (6*60*60) - static time_t last_warned = 0; - time_t now = time(NULL); - int n_conns = get_n_open_sockets(); - if (last_warned + WARN_TOO_MANY_CONNS_INTERVAL < now) { + static ratelim_t last_warned = RATELIM_INIT(WARN_TOO_MANY_CONNS_INTERVAL); + char *m; + if ((m = rate_limit_log(&last_warned, approx_time()))) { + int n_conns = get_n_open_sockets(); log_warn(LD_NET,"Failing because we have %d connections already. Please " - "raise your ulimit -n.", n_conns); - last_warned = now; + "raise your ulimit -n.%s", n_conns, m); + tor_free(m); control_event_general_status(LOG_WARN, "TOO_MANY_CONNECTIONS CURRENT=%d", n_conns); } |