aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@ev0ke.net>2014-11-04 00:19:31 -0500
committerNick Mathewson <nickm@torproject.org>2014-11-04 00:19:31 -0500
commit71355e1db937b0b940bb9510c927e3e500cabc22 (patch)
treeb96a4eafd56bcff89ce191b5c8c8aaaad757b690 /src
parenta142fc29aff4b47640a1a4f59032e25b7360e847 (diff)
downloadtor-71355e1db937b0b940bb9510c927e3e500cabc22.tar.gz
tor-71355e1db937b0b940bb9510c927e3e500cabc22.zip
Add comments and rename intro_nodes list in rend_services_introduce()
(No changes file needed: this patch just adds comments and renames variables. This is ticket 13646. message taken from the ticket. -Nick)
Diffstat (limited to 'src')
-rw-r--r--src/or/rendservice.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/or/rendservice.c b/src/or/rendservice.c
index 392f393317..c586132995 100644
--- a/src/or/rendservice.c
+++ b/src/or/rendservice.c
@@ -3028,15 +3028,16 @@ rend_services_introduce(void)
int intro_point_set_changed, prev_intro_nodes;
unsigned int n_intro_points_unexpired;
unsigned int n_intro_points_to_open;
- smartlist_t *intro_nodes;
time_t now;
const or_options_t *options = get_options();
+ /* List of nodes we need to _exclude_ when choosing a new node to establish
+ * an intro point to. */
+ smartlist_t *exclude_nodes = smartlist_new();
- intro_nodes = smartlist_new();
now = time(NULL);
for (i=0; i < smartlist_len(rend_service_list); ++i) {
- smartlist_clear(intro_nodes);
+ smartlist_clear(exclude_nodes);
service = smartlist_get(rend_service_list, i);
tor_assert(service);
@@ -3135,8 +3136,10 @@ rend_services_introduce(void)
if (intro != NULL && intro->time_expiring == -1)
++n_intro_points_unexpired;
+ /* Add the valid node to the exclusion list so we don't try to establish
+ * an introduction point to it again. */
if (node)
- smartlist_add(intro_nodes, (void*)node);
+ smartlist_add(exclude_nodes, (void*)node);
} SMARTLIST_FOREACH_END(intro);
if (!intro_point_set_changed &&
@@ -3172,7 +3175,7 @@ rend_services_introduce(void)
router_crn_flags_t flags = CRN_NEED_UPTIME|CRN_NEED_DESC;
if (get_options()->AllowInvalid_ & ALLOW_INVALID_INTRODUCTION)
flags |= CRN_ALLOW_INVALID;
- node = router_choose_random_node(intro_nodes,
+ node = router_choose_random_node(exclude_nodes,
options->ExcludeNodes, flags);
if (!node) {
log_warn(LD_REND,
@@ -3183,7 +3186,9 @@ rend_services_introduce(void)
break;
}
intro_point_set_changed = 1;
- smartlist_add(intro_nodes, (void*)node);
+ /* Add the choosen node to the exclusion list in order to avoid to pick
+ * it again in the next iteration. */
+ smartlist_add(exclude_nodes, (void*)node);
intro = tor_malloc_zero(sizeof(rend_intro_point_t));
intro->extend_info = extend_info_from_node(node, 0);
intro->intro_key = crypto_pk_new();
@@ -3212,7 +3217,7 @@ rend_services_introduce(void)
}
}
}
- smartlist_free(intro_nodes);
+ smartlist_free(exclude_nodes);
}
/** Regenerate and upload rendezvous service descriptors for all