From: Roger Dingledine Date: Fri, 19 Jan 2018 07:38:07 +0000 (-0500) Subject: turn MAX_REND_FAILURES into a function X-Git-Tag: tor-0.2.9.15~17^2^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=cc5a9e96674f39677a65daa2f7a2f5af7ac3106e;p=thirdparty%2Ftor.git turn MAX_REND_FAILURES into a function no actual changes in behavior --- diff --git a/src/or/rendservice.c b/src/or/rendservice.c index acc431a577..b503eda7ff 100644 --- a/src/or/rendservice.c +++ b/src/or/rendservice.c @@ -108,13 +108,18 @@ struct rend_service_port_config_s { /** Don't try to build more than this many circuits before giving up * for a while.*/ #define MAX_INTRO_CIRCS_PER_PERIOD 10 -/** How many times will a hidden service operator attempt to connect to - * a requested rendezvous point before giving up? */ -#define MAX_REND_FAILURES 1 /** How many seconds should we spend trying to connect to a requested * rendezvous point before giving up? */ #define MAX_REND_TIMEOUT 30 +/** How many times will a hidden service operator attempt to connect to + * a requested rendezvous point before giving up? */ +static int +get_max_rend_failures(void) +{ + return 1; +} + /* Hidden service directory file names: * new file names should be added to rend_service_add_filenames_to_list() * for sandboxing purposes. */ @@ -2028,7 +2033,8 @@ rend_service_receive_introduction(origin_circuit_t *circuit, /* Launch a circuit to the client's chosen rendezvous point. */ - for (i=0;ihs_service_side_rend_circ_has_been_relaunched = 1; - /* We check failure_count >= MAX_REND_FAILURES-1 below rather than - * failure_count >= MAX_REND_FAILURES, because we increment the failure - * count for our current failure *after* this clause. */ + /* We check failure_count >= get_max_rend_failures()-1 below, and the -1 + * is because we increment the failure count for our current failure + * *after* this clause. */ + int max_rend_failures = get_max_rend_failures() - 1; + if (!oldcirc->build_state || - oldcirc->build_state->failure_count >= MAX_REND_FAILURES-1 || + oldcirc->build_state->failure_count >= max_rend_failures || oldcirc->build_state->expiry_time < time(NULL)) { log_info(LD_REND, "Attempt to build circuit to %s for rendezvous has failed "