summaryrefslogtreecommitdiff
path: root/src/or/circuitbuild.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2011-07-11 11:21:47 -0400
committerNick Mathewson <nickm@torproject.org>2011-07-11 11:21:47 -0400
commite158f8de4b487450adeb89de204898263f6a87a5 (patch)
tree1fef7d1c700208ead34667200f138088635481b8 /src/or/circuitbuild.c
parent60832766ac19e8f027455d23254e376042c21ef2 (diff)
downloadtor-e158f8de4b487450adeb89de204898263f6a87a5.tar.gz
tor-e158f8de4b487450adeb89de204898263f6a87a5.zip
Rename and tweak nodelist_add_node_family() to add node
It's very easy for nodelist_add_node_family(sl,node) to accidentally add 'node', and kind of hard to make sure that it omits it. Instead of taking pains to leave 'node' out, let's instead make sure that we always include it. I also rename the function to nodelist_add_node_and_family, and audit its users so that they don't add the node itself any longer, since the function will take care of that for them. Resolves bug 2616, which was not actually a bug.
Diffstat (limited to 'src/or/circuitbuild.c')
-rw-r--r--src/or/circuitbuild.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index 90d92802ea..df335571af 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -3102,13 +3102,11 @@ choose_good_middle_server(uint8_t purpose,
log_debug(LD_CIRC, "Contemplating intermediate hop: random choice.");
excluded = smartlist_create();
if ((r = build_state_get_exit_node(state))) {
- smartlist_add(excluded, (void*) r);
- nodelist_add_node_family(excluded, r);
+ nodelist_add_node_and_family(excluded, r);
}
for (i = 0, cpath = head; i < cur_len; ++i, cpath=cpath->next) {
if ((r = node_get_by_id(cpath->extend_info->identity_digest))) {
- smartlist_add(excluded, (void*)r);
- nodelist_add_node_family(excluded, r);
+ nodelist_add_node_and_family(excluded, r);
}
}
@@ -3152,8 +3150,7 @@ choose_good_entry_server(uint8_t purpose, cpath_build_state_t *state)
if (state && (node = build_state_get_exit_node(state))) {
/* Exclude the exit node from the state, if we have one. Also exclude its
* family. */
- smartlist_add(excluded, (void*)node);
- nodelist_add_node_family(excluded, node);
+ nodelist_add_node_and_family(excluded, node);
}
if (firewall_is_fascist_or()) {
/* Exclude all ORs that we can't reach through our firewall */
@@ -3168,8 +3165,7 @@ choose_good_entry_server(uint8_t purpose, cpath_build_state_t *state)
SMARTLIST_FOREACH(entry_guards, entry_guard_t *, entry,
{
if ((node = node_get_by_id(entry->identity))) {
- smartlist_add(excluded, (void*)node);
- nodelist_add_node_family(excluded, node);
+ nodelist_add_node_and_family(excluded, node);
}
});
}
@@ -4094,7 +4090,7 @@ choose_random_entry(cpath_build_state_t *state)
int preferred_min, consider_exit_family = 0;
if (chosen_exit) {
- nodelist_add_node_family(exit_family, chosen_exit);
+ nodelist_add_node_and_family(exit_family, chosen_exit);
consider_exit_family = 1;
}