[or-cvs] make cannibalizing for rend circs prey on the pleb circs fi...

Roger Dingledine arma at seul.org
Wed Jan 19 23:13:23 UTC 2005


Update of /home2/or/cvsroot/tor/src/or
In directory moria.mit.edu:/home2/arma/work/onion/cvs/tor/src/or

Modified Files:
	circuitlist.c 
Log Message:
make cannibalizing for rend circs prey on the pleb circs first
if possible, rather than the elite ones.


Index: circuitlist.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/circuitlist.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- circuitlist.c	17 Jan 2005 18:13:09 -0000	1.23
+++ circuitlist.c	19 Jan 2005 23:13:20 -0000	1.24
@@ -295,11 +295,16 @@
 /** 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 @@
         !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



More information about the tor-commits mailing list