Add a generic rate-limited log mechanism, and use it in a few places

Incidentally fixes bug 1042.
This commit is contained in:
Nick Mathewson
2010-08-18 15:55:49 -04:00
parent d72edc4b78
commit ba9c1275c4
6 changed files with 96 additions and 12 deletions
+6 -1
View File
@@ -288,7 +288,12 @@ 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.");
static ratelim_t handoff_warning = RATELIM_INIT(3600);
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;
}