diff options
author | David Goulet <dgoulet@torproject.org> | 2017-08-04 12:06:34 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-08-08 20:29:35 -0400 |
commit | 400ba2f636edf5afb14fe3b57f23d80e433d893d (patch) | |
tree | b88548d7c08bf3c6a190247e18a026c1cdd333f1 /src/or/circuituse.c | |
parent | 0a0bbfe96fe425f27641f86fabd19f65a551ac6c (diff) | |
download | tor-400ba2f636edf5afb14fe3b57f23d80e433d893d.tar.gz tor-400ba2f636edf5afb14fe3b57f23d80e433d893d.zip |
prop224: Always note down the use of internal circuit
Also, this removes all the callsite of this rephist in the hs subsystem
Fixes #23097
Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/or/circuituse.c')
-rw-r--r-- | src/or/circuituse.c | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/src/or/circuituse.c b/src/or/circuituse.c index 5292dc01db..66006542d0 100644 --- a/src/or/circuituse.c +++ b/src/or/circuituse.c @@ -1114,11 +1114,32 @@ needs_exit_circuits(time_t now, int *needs_uptime, int *needs_capacity) /* Return true if we need any more hidden service server circuits. * HS servers only need an internal circuit. */ STATIC int -needs_hs_server_circuits(int num_uptime_internal) +needs_hs_server_circuits(time_t now, int num_uptime_internal) { - return ((rend_num_services() || hs_service_get_num_services()) && - num_uptime_internal < SUFFICIENT_UPTIME_INTERNAL_HS_SERVERS && - router_have_consensus_path() != CONSENSUS_PATH_UNKNOWN); + if (!rend_num_services() && !hs_service_get_num_services()) { + /* No services, we don't need anything. */ + goto no_need; + } + + if (num_uptime_internal >= SUFFICIENT_UPTIME_INTERNAL_HS_SERVERS) { + /* We have sufficient amount of internal circuit. */ + goto no_need; + } + + if (router_have_consensus_path() == CONSENSUS_PATH_UNKNOWN) { + /* Consensus hasn't been checked or might be invalid so requesting + * internal circuits is not wise. */ + goto no_need; + } + + /* At this point, we need a certain amount of circuits and we will most + * likely use them for rendezvous so we note down the use of internal + * circuit for our prediction for circuit needing uptime and capacity. */ + rep_hist_note_used_internal(now, 1, 1); + + return 1; + no_need: + return 0; } /* We need at least this many internal circuits for hidden service clients */ @@ -1217,7 +1238,7 @@ circuit_predict_and_launch_new(void) return; } - if (needs_hs_server_circuits(num_uptime_internal)) { + if (needs_hs_server_circuits(now, num_uptime_internal)) { flags = (CIRCLAUNCH_NEED_CAPACITY | CIRCLAUNCH_NEED_UPTIME | CIRCLAUNCH_IS_INTERNAL); |