mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-10 21:23:58 +01:00
short-circuit half the cost of node-picking in the general case.
svn:r5732
This commit is contained in:
parent
1107c40dc0
commit
6aaa92f736
@ -809,13 +809,14 @@ router_choose_random_node(const char *preferred,
|
||||
int allow_unverified, int strict)
|
||||
{
|
||||
smartlist_t *sl, *excludednodes;
|
||||
routerinfo_t *choice;
|
||||
routerinfo_t *choice = NULL;
|
||||
|
||||
excludednodes = smartlist_create();
|
||||
add_nickname_list_to_smartlist(excludednodes,excluded,0,0,1);
|
||||
|
||||
/* Try the preferred nodes first. Ignore need_uptime and need_capacity,
|
||||
* since the user explicitly asked for these nodes. */
|
||||
if (preferred) {
|
||||
sl = smartlist_create();
|
||||
add_nickname_list_to_smartlist(sl,preferred,1,1,1);
|
||||
smartlist_subtract(sl,excludednodes);
|
||||
@ -823,6 +824,7 @@ router_choose_random_node(const char *preferred,
|
||||
smartlist_subtract(sl,excludedsmartlist);
|
||||
choice = smartlist_choose(sl);
|
||||
smartlist_free(sl);
|
||||
}
|
||||
if (!choice && !strict) {
|
||||
/* Then give up on our preferred choices: any node
|
||||
* will do that has the required attributes. */
|
||||
|
Loading…
Reference in New Issue
Block a user