[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] [tor/master 10/15] More debugging code for node_t branch



Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date: Fri, 1 Oct 2010 19:52:05 -0400
Subject: More debugging code for node_t branch
Commit: b9f2ccbdcc222869b7561714c285db8b47e52e77

---
 src/or/circuitbuild.c |   13 ++++++++++---
 src/or/nodelist.c     |    7 ++++---
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index 58d4e60..f485574 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -2564,7 +2564,7 @@ choose_good_exit_server_general(int need_uptime, int need_capacity)
        */
       continue;
     }
-    if (!node->ri && !(node->rs && node->md))
+    if (!node_has_descriptor(node))
       continue;
     if (!node->is_running || node->is_bad_exit) {
       n_supported[i] = -1;
@@ -2684,6 +2684,8 @@ choose_good_exit_server_general(int need_uptime, int need_capacity)
       /* try once to pick only from routers that satisfy a needed port,
        * then if there are none, pick from any that support exiting. */
       SMARTLIST_FOREACH_BEGIN(the_nodes, const node_t *, node) {
+        if (!node_has_descriptor(node))
+          continue;
         if (n_supported[node_sl_idx] != -1 &&
             (attempt || node_handles_some_port(node, needed_ports))) {
 //          log_fn(LOG_DEBUG,"Try %d: '%s' is a possibility.",
@@ -2860,6 +2862,7 @@ onion_pick_cpath_exit(origin_circuit_t *circ, extend_info_t *exit)
       return -1;
     }
     exit = extend_info_from_node(node);
+    tor_assert(exit);
   }
   state->chosen_exit = exit;
   return 0;
@@ -3100,13 +3103,17 @@ onion_extend_cpath(origin_circuit_t *circ)
     info = extend_info_dup(state->chosen_exit);
   } else if (cur_len == 0) { /* picking first node */
     const node_t *r = choose_good_entry_server(purpose, state);
-    if (r)
+    if (r) {
       info = extend_info_from_node(r);
+      tor_assert(info);
+    }
   } else {
     const node_t *r =
       choose_good_middle_server(purpose, state, circ->cpath, cur_len);
-    if (r)
+    if (r) {
       info = extend_info_from_node(r);
+      tor_assert(info);
+    }
   }
 
   if (!info) {
diff --git a/src/or/nodelist.c b/src/or/nodelist.c
index d303fc6..a7946c9 100644
--- a/src/or/nodelist.c
+++ b/src/or/nodelist.c
@@ -593,9 +593,10 @@ node_get_verbose_nickname(const node_t *node,
 int
 node_allows_single_hop_exits(const node_t *node)
 {
-  (void)node;
-  UNIMPLEMENTED_NODELIST();
-  return 0;
+  if (node && node->ri)
+    return node->ri->allow_single_hop_exits;
+  else
+    return 0;
 }
 
 /** Return true iff it seems that <b>node</b> has an exit policy that doesn't
-- 
1.7.1