Add circuit time check before logging about relaxing circuit time

Signed-off-by: José M. Guisado <guigom@riseup.net>
This commit is contained in:
José M. Guisado 2019-01-23 00:04:57 +01:00 committed by Nick Mathewson
parent d83c299eba
commit 78220aae1e
2 changed files with 21 additions and 12 deletions

3
changes/bug28698 Normal file
View File

@ -0,0 +1,3 @@
o Minor bugfix (logging):
- Avoid logging about relaxing circuits when their time is fixed.
Fixes bug 28698; bugfix on 0.2.4.7-alpha

View File

@ -545,6 +545,8 @@ circuit_expire_building(void)
SMARTLIST_FOREACH_BEGIN(circuit_get_global_list(), circuit_t *,victim) { SMARTLIST_FOREACH_BEGIN(circuit_get_global_list(), circuit_t *,victim) {
struct timeval cutoff; struct timeval cutoff;
bool fixed_time = circuit_build_times_disabled(get_options());
if (!CIRCUIT_IS_ORIGIN(victim) || /* didn't originate here */ if (!CIRCUIT_IS_ORIGIN(victim) || /* didn't originate here */
victim->marked_for_close) /* don't mess with marked circs */ victim->marked_for_close) /* don't mess with marked circs */
continue; continue;
@ -599,6 +601,7 @@ circuit_expire_building(void)
if (!TO_ORIGIN_CIRCUIT(victim)->relaxed_timeout) { if (!TO_ORIGIN_CIRCUIT(victim)->relaxed_timeout) {
int first_hop_succeeded = TO_ORIGIN_CIRCUIT(victim)->cpath->state int first_hop_succeeded = TO_ORIGIN_CIRCUIT(victim)->cpath->state
== CPATH_STATE_OPEN; == CPATH_STATE_OPEN;
if (!fixed_time) {
log_info(LD_CIRC, log_info(LD_CIRC,
"No circuits are opened. Relaxing timeout for circuit %d " "No circuits are opened. Relaxing timeout for circuit %d "
"(a %s %d-hop circuit in state %s with channel state %s).", "(a %s %d-hop circuit in state %s with channel state %s).",
@ -610,6 +613,7 @@ circuit_expire_building(void)
circuit_state_to_string(victim->state), circuit_state_to_string(victim->state),
victim->n_chan ? victim->n_chan ?
channel_state_to_string(victim->n_chan->state) : "none"); channel_state_to_string(victim->n_chan->state) : "none");
}
/* We count the timeout here for CBT, because technically this /* We count the timeout here for CBT, because technically this
* was a timeout, and the timeout value needs to reset if we * was a timeout, and the timeout value needs to reset if we
@ -623,6 +627,7 @@ circuit_expire_building(void)
} else { } else {
static ratelim_t relax_timeout_limit = RATELIM_INIT(3600); static ratelim_t relax_timeout_limit = RATELIM_INIT(3600);
const double build_close_ms = get_circuit_build_close_time_ms(); const double build_close_ms = get_circuit_build_close_time_ms();
if (!fixed_time) {
log_fn_ratelim(&relax_timeout_limit, LOG_NOTICE, LD_CIRC, log_fn_ratelim(&relax_timeout_limit, LOG_NOTICE, LD_CIRC,
"No circuits are opened. Relaxed timeout for circuit %d " "No circuits are opened. Relaxed timeout for circuit %d "
"(a %s %d-hop circuit in state %s with channel state %s) to " "(a %s %d-hop circuit in state %s with channel state %s) to "
@ -639,6 +644,7 @@ circuit_expire_building(void)
(long)build_close_ms); (long)build_close_ms);
} }
} }
}
#if 0 #if 0
/* some debug logs, to help track bugs */ /* some debug logs, to help track bugs */