[or-cvs] r11184: generalize circuit_find_to_cannibalize() so it knows what pu (tor/trunk/src/or)

arma at seul.org arma at seul.org
Sun Aug 19 07:04:24 UTC 2007


Author: arma
Date: 2007-08-19 03:04:24 -0400 (Sun, 19 Aug 2007)
New Revision: 11184

Modified:
   tor/trunk/src/or/circuitlist.c
   tor/trunk/src/or/circuituse.c
Log:
generalize circuit_find_to_cannibalize() so it knows what
purpose circuit we're planning to become


Modified: tor/trunk/src/or/circuitlist.c
===================================================================
--- tor/trunk/src/or/circuitlist.c	2007-08-19 05:51:10 UTC (rev 11183)
+++ tor/trunk/src/or/circuitlist.c	2007-08-19 07:04:24 UTC (rev 11184)
@@ -787,7 +787,7 @@
                                      DIGEST_LEN);
 }
 
-/** Return a circuit that is open, has specified <b>purpose</b>,
+/** 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_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 @@
     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)) {

Modified: tor/trunk/src/or/circuituse.c
===================================================================
--- tor/trunk/src/or/circuituse.c	2007-08-19 05:51:10 UTC (rev 11183)
+++ tor/trunk/src/or/circuituse.c	2007-08-19 07:04:24 UTC (rev 11184)
@@ -836,7 +836,7 @@
   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",



More information about the tor-commits mailing list