aboutsummaryrefslogtreecommitdiff
path: root/src/or
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2010-08-31 12:59:36 -0400
committerNick Mathewson <nickm@torproject.org>2010-08-31 12:59:36 -0400
commit20817403173dcd2f8128c9c8b14491117cdc40b6 (patch)
treefb4fc1790daaf6d451a2876eb8b274dafb6daa1f /src/or
parentc66138609a489bb8aa312ead04aebd1bc65e679c (diff)
parent285addbd943cbc9e96c0a268f4f45510270b4468 (diff)
downloadtor-20817403173dcd2f8128c9c8b14491117cdc40b6.tar
tor-20817403173dcd2f8128c9c8b14491117cdc40b6.tar.gz
Merge branch 'ratelim'
Diffstat (limited to 'src/or')
-rw-r--r--src/or/command.c9
-rw-r--r--src/or/connection.c12
-rw-r--r--src/or/onion.c11
3 files changed, 20 insertions, 12 deletions
diff --git a/src/or/command.c b/src/or/command.c
index 0460e25c2..ea0bbea1e 100644
--- a/src/or/command.c
+++ b/src/or/command.c
@@ -288,7 +288,14 @@ command_process_create_cell(cell_t *cell, or_connection_t *conn)
/* hand it off to the cpuworkers, and then return. */
if (assign_onionskin_to_cpuworker(NULL, circ, onionskin) < 0) {
- log_warn(LD_GENERAL,"Failed to hand off onionskin. Closing.");
+#define WARN_HANDOFF_FAILURE_INTERVAL (6*60*60)
+ static ratelim_t handoff_warning =
+ RATELIM_INIT(WARN_HANDOFF_FAILURE_INTERVAL);
+ char *m;
+ if ((m = rate_limit_log(&handoff_warning, approx_time()))) {
+ log_warn(LD_GENERAL,"Failed to hand off onionskin. Closing.%s",m);
+ tor_free(m);
+ }
circuit_mark_for_close(TO_CIRCUIT(circ), END_CIRC_REASON_INTERNAL);
return;
}
diff --git a/src/or/connection.c b/src/or/connection.c
index c040be041..91ce74b5b 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);
}
diff --git a/src/or/onion.c b/src/or/onion.c
index ebc358364..fa001656e 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;