diff options
author | Roger Dingledine <arma@torproject.org> | 2005-01-19 23:13:20 +0000 |
---|---|---|
committer | Roger Dingledine <arma@torproject.org> | 2005-01-19 23:13:20 +0000 |
commit | ff48179372853bc7625981503c58a06cd509462a (patch) | |
tree | 90ca58972ed369b3456bc8d127c81e852372eeae /src | |
parent | f8c14bbf1fb216d04b076627e2cc0c1d9afce722 (diff) | |
download | tor-ff48179372853bc7625981503c58a06cd509462a.tar tor-ff48179372853bc7625981503c58a06cd509462a.tar.gz |
make cannibalizing for rend circs prey on the pleb circs first
if possible, rather than the elite ones.
svn:r3378
Diffstat (limited to 'src')
-rw-r--r-- | src/or/circuitlist.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/or/circuitlist.c b/src/or/circuitlist.c index 643e360c3..4eabb9810 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 <b>purpose</b>, * 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 <b>circ</b> to be closed next time we call |