mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-24 12:23:32 +01:00
refactor and recomment; no actual changes
This commit is contained in:
parent
f1b0e4e4b4
commit
7f10707c42
@ -149,6 +149,14 @@ circuit_build_times_min_circs_to_observe(void)
|
||||
return num;
|
||||
}
|
||||
|
||||
/** Return true iff <b>cbt</b> has recorded enough build times that we
|
||||
* want to start acting on the timeout it implies. */
|
||||
int
|
||||
circuit_build_times_enough_to_compute(circuit_build_times_t *cbt)
|
||||
{
|
||||
return cbt->total_build_times >= circuit_build_times_min_circs_to_observe();
|
||||
}
|
||||
|
||||
double
|
||||
circuit_build_times_quantile_cutoff(void)
|
||||
{
|
||||
@ -292,8 +300,8 @@ circuit_build_times_reset(circuit_build_times_t *cbt)
|
||||
/**
|
||||
* Initialize the buildtimes structure for first use.
|
||||
*
|
||||
* Sets the initial timeout value based to either the
|
||||
* config setting or BUILD_TIMEOUT_INITIAL_VALUE.
|
||||
* Sets the initial timeout values based on either the config setting,
|
||||
* the consensus param, or the default (CBT_DEFAULT_TIMEOUT_INITIAL_VALUE).
|
||||
*/
|
||||
void
|
||||
circuit_build_times_init(circuit_build_times_t *cbt)
|
||||
@ -918,9 +926,7 @@ int
|
||||
circuit_build_times_needs_circuits(circuit_build_times_t *cbt)
|
||||
{
|
||||
/* Return true if < MIN_CIRCUITS_TO_OBSERVE */
|
||||
if (cbt->total_build_times < circuit_build_times_min_circs_to_observe())
|
||||
return 1;
|
||||
return 0;
|
||||
return !circuit_build_times_enough_to_compute(cbt);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1205,9 +1211,8 @@ static int
|
||||
circuit_build_times_set_timeout_worker(circuit_build_times_t *cbt)
|
||||
{
|
||||
build_time_t max_time;
|
||||
if (cbt->total_build_times < circuit_build_times_min_circs_to_observe()) {
|
||||
if (!circuit_build_times_enough_to_compute(cbt))
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!circuit_build_times_update_alpha(cbt))
|
||||
return 0;
|
||||
|
@ -79,6 +79,7 @@ void bridges_retry_all(void);
|
||||
void entry_guards_free_all(void);
|
||||
|
||||
extern circuit_build_times_t circ_times;
|
||||
int circuit_build_times_enough_to_compute(circuit_build_times_t *cbt);
|
||||
void circuit_build_times_update_state(circuit_build_times_t *cbt,
|
||||
or_state_t *state);
|
||||
int circuit_build_times_parse_state(circuit_build_times_t *cbt,
|
||||
|
@ -278,8 +278,9 @@ void
|
||||
circuit_expire_building(time_t now)
|
||||
{
|
||||
circuit_t *victim, *next_circ = global_circuitlist;
|
||||
/* circ_times.timeout is BUILD_TIMEOUT_INITIAL_VALUE if we haven't
|
||||
* decided on a customized one yet */
|
||||
/* circ_times.timeout_ms and circ_times.close_ms are from
|
||||
* circuit_build_times_get_initial_timeout() if we haven't computed
|
||||
* custom timeouts yet */
|
||||
time_t general_cutoff = now - tor_lround(circ_times.timeout_ms/1000);
|
||||
time_t begindir_cutoff = now - tor_lround(circ_times.timeout_ms/2000);
|
||||
time_t fourhop_cutoff = now - tor_lround(4*circ_times.timeout_ms/3000);
|
||||
|
@ -2979,8 +2979,9 @@ typedef uint32_t build_time_t;
|
||||
* Maximum count of timeouts that finish the first hop in the past
|
||||
* RECENT_CIRCUITS before calculating a new timeout.
|
||||
*
|
||||
* This tells us to abandon timeout history and set
|
||||
* the timeout back to BUILD_TIMEOUT_INITIAL_VALUE.
|
||||
* This tells us whether to abandon timeout history and set
|
||||
* the timeout back to whatever circuit_build_times_get_initial_timeout()
|
||||
* gives us.
|
||||
*/
|
||||
#define CBT_DEFAULT_MAX_RECENT_TIMEOUT_COUNT (CBT_DEFAULT_RECENT_CIRCUITS*9/10)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user