From 03560d575e16ddcf980bc7b2f8ee2f9689c2ccb0 Mon Sep 17 00:00:00 2001 From: Roger Dingledine Date: Sun, 19 Aug 2007 07:04:24 +0000 Subject: generalize circuit_find_to_cannibalize() so it knows what purpose circuit we're planning to become svn:r11184 --- src/or/circuitlist.c | 13 +++++++++++-- src/or/circuituse.c | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/or/circuitlist.c b/src/or/circuitlist.c index f199af206..fa03c3515 100644 --- a/src/or/circuitlist.c +++ b/src/or/circuitlist.c @@ -787,7 +787,7 @@ circuit_get_intro_point(const char *digest) DIGEST_LEN); } -/** Return a circuit that is open, has specified purpose, +/** Return a circuit that is open, is CIRCUIT_PURPOSE_C_GENERAL, * has a timestamp_dirty value of 0, is uptime/capacity/internal * if required, and if info is defined, does not already use info * as any of its hops; or NULL if no circuit fits this description. @@ -801,6 +801,7 @@ circuit_find_to_cannibalize(uint8_t purpose, extend_info_t *info, { circuit_t *_circ; origin_circuit_t *best=NULL; + or_options_t *options = get_options(); log_debug(LD_CIRC, "Hunting for a circ to cannibalize: purpose %d, uptime %d, " @@ -811,9 +812,17 @@ circuit_find_to_cannibalize(uint8_t purpose, extend_info_t *info, if (CIRCUIT_IS_ORIGIN(_circ) && _circ->state == CIRCUIT_STATE_OPEN && !_circ->marked_for_close && - _circ->purpose == purpose && + _circ->purpose == CIRCUIT_PURPOSE_C_GENERAL && !_circ->timestamp_dirty) { origin_circuit_t *circ = TO_ORIGIN_CIRCUIT(_circ); +#if 0 /* XXX here while roger investigates a reported RendNodes bug */ + if (_circ->purpose == CIRCUIT_PURPOSE_C_ESTABLISH_REND && + options->RendNodes) { + routerinfo_t *exit = build_state_get_exit_router(circ->build_state); + if (exit && !router_nickname_is_in_list(exit, options->RendNodes)) + continue; /* not one of our allowed RendNodes */ + } +#endif if ((!need_uptime || circ->build_state->need_uptime) && (!need_capacity || circ->build_state->need_capacity) && (internal == circ->build_state->is_internal)) { diff --git a/src/or/circuituse.c b/src/or/circuituse.c index 5b866b9df..ee9f7cae9 100644 --- a/src/or/circuituse.c +++ b/src/or/circuituse.c @@ -836,7 +836,7 @@ circuit_launch_by_extend_info(uint8_t purpose, int onehop_tunnel, if ((extend_info || purpose != CIRCUIT_PURPOSE_C_GENERAL) && purpose != CIRCUIT_PURPOSE_TESTING && !onehop_tunnel) { /* see if there are appropriate circs available to cannibalize. */ - circ = circuit_find_to_cannibalize(CIRCUIT_PURPOSE_C_GENERAL, extend_info, + circ = circuit_find_to_cannibalize(purpose, extend_info, need_uptime, need_capacity, internal); if (circ) { log_info(LD_CIRC,"Cannibalizing circ '%s' for purpose %d", -- cgit v1.2.3