Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tor
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
The Tor Project
Core
debian
tor
Commits
a59429f1
Commit
a59429f1
authored
10 years ago
by
George Kadianakis
Browse files
Options
Downloads
Patches
Plain Diff
Fix the functionality of populate_live_entry_guards().
parent
427cc8a4
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/or/entrynodes.c
+38
-10
38 additions, 10 deletions
src/or/entrynodes.c
with
38 additions
and
10 deletions
src/or/entrynodes.c
+
38
−
10
View file @
a59429f1
...
...
@@ -995,14 +995,24 @@ choose_random_dirguard(dirinfo_type_t type)
return
choose_random_entry_impl
(
NULL
,
1
,
type
,
NULL
);
}
/* DOCDOCODC
Return 1 if we should choose a guard right away. */
static
int
populate_live_entry_guards
(
const
smartlist_t
*
live_entry_guards
,
populate_live_entry_guards
(
smartlist_t
*
live_entry_guards
,
const
node_t
*
chosen_exit
,
dirinfo_type_t
dirinfo_type
,
int
need_uptime
,
int
need_capacity
,
int
need_descriptor
)
int
for_directory
,
int
need_uptime
,
int
need_capacity
)
{
const
or_options_t
*
options
=
get_options
();
const
node_t
*
node
=
NULL
;
const
int
num_needed
=
decide_num_guards
(
options
,
for_directory
);
smartlist_t
*
exit_family
=
smartlist_new
();
int
retval
=
0
;
int
need_descriptor
=
!
for_directory
;
tor_assert
(
entry_guards
);
if
(
chosen_exit
)
{
nodelist_add_node_and_family
(
exit_family
,
chosen_exit
);
}
...
...
@@ -1030,11 +1040,19 @@ populate_live_entry_guards(const smartlist_t *live_entry_guards,
* guard. Otherwise we might add several new ones, pick
* the second new one, and now we've expanded our entry
* guard list without needing to. */
goto
choose_and_finish
;
retval
=
1
;
goto
done
;
}
if
(
smartlist_len
(
live_entry_guards
)
>=
num_needed
)
{
retval
=
1
;
goto
done
;
/* We picked enough entry guards. Done! */
}
if
(
smartlist_len
(
live_entry_guards
)
>=
num_needed
)
goto
choose_and_finish
;
/* we have enough */
}
SMARTLIST_FOREACH_END
(
entry
);
done:
smartlist_free
(
exit_family
);
return
retval
;
}
/** Helper for choose_random{entry,dirguard}. */
...
...
@@ -1044,15 +1062,14 @@ choose_random_entry_impl(cpath_build_state_t *state, int for_directory,
{
const
or_options_t
*
options
=
get_options
();
smartlist_t
*
live_entry_guards
=
smartlist_new
();
smartlist_t
*
exit_family
=
smartlist_new
();
const
node_t
*
chosen_exit
=
state
?
build_state_get_exit_node
(
state
)
:
NULL
;
const
node_t
*
node
=
NULL
;
int
need_uptime
=
state
?
state
->
need_uptime
:
0
;
int
need_capacity
=
state
?
state
->
need_capacity
:
0
;
int
preferred_min
=
0
;
int
need_descriptor
=
!
for_directory
;
const
int
num_needed
=
decide_num_guards
(
options
,
for_directory
);
int
retval
=
0
;
if
(
n_options_out
)
*
n_options_out
=
0
;
...
...
@@ -1070,6 +1087,18 @@ choose_random_entry_impl(cpath_build_state_t *state, int for_directory,
retry:
smartlist_clear
(
live_entry_guards
);
/* Populate the list of live entry guards so that we pick one of
them. */
retval
=
populate_live_entry_guards
(
live_entry_guards
,
chosen_exit
,
dirinfo_type
,
for_directory
,
need_uptime
,
need_capacity
);
if
(
retval
==
1
)
{
/* We should choose a guard right now. */
goto
choose_and_finish
;
}
if
(
entry_list_is_constrained
(
options
))
{
/* If we prefer the entry nodes we've got, and we have at least
* one choice, that's great. Use it. */
...
...
@@ -1126,7 +1155,6 @@ choose_random_entry_impl(cpath_build_state_t *state, int for_directory,
if
(
n_options_out
)
*
n_options_out
=
smartlist_len
(
live_entry_guards
);
smartlist_free
(
live_entry_guards
);
smartlist_free
(
exit_family
);
return
node
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment