From: Roger Dingledine Date: Wed, 19 Jan 2005 23:13:20 +0000 (+0000) Subject: make cannibalizing for rend circs prey on the pleb circs first X-Git-Tag: tor-0.1.0.1-rc~443 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ff48179372853bc7625981503c58a06cd509462a;p=thirdparty%2Ftor.git make cannibalizing for rend circs prey on the pleb circs first if possible, rather than the elite ones. svn:r3378 --- diff --git a/src/or/circuitlist.c b/src/or/circuitlist.c index 643e360c35..4eabb9810b 100644 --- a/src/or/circuitlist.c +++ b/src/or/circuitlist.c @@ -295,11 +295,16 @@ circuit_t *circuit_get_rendezvous(const char *cookie) /** Return a circuit that is open, has specified purpose, * has a timestamp_dirty value of 0, and is uptime/capacity/internal * if required; or NULL if no circuit fits this description. + * + * Avoid returning need_uptime circuits if not necessary. + * FFFF As a more important goal, not yet implemented, avoid returning + * internal circuits if not necessary. */ circuit_t * circuit_get_clean_open(uint8_t purpose, int need_uptime, int need_capacity, int internal) { circuit_t *circ; + circuit_t *best=NULL; log_fn(LOG_DEBUG,"Hunting for a circ to cannibalize: purpose %d, uptime %d, capacity %d, internal %d", purpose, need_uptime, need_capacity, internal); @@ -311,10 +316,12 @@ circuit_get_clean_open(uint8_t purpose, int need_uptime, !circ->timestamp_dirty && (!need_uptime || circ->build_state->need_uptime) && (!need_capacity || circ->build_state->need_capacity) && - (!internal || circ->build_state->is_internal)) - return circ; + (!internal || circ->build_state->is_internal)) { + if (!best || (best->build_state->need_uptime && !need_uptime)) + best = circ; + } } - return NULL; + return best; } /** Mark circ to be closed next time we call