Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tor
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
jarl
tor
Commits
685bceed
Commit
685bceed
authored
19 years ago
by
Nick Mathewson
Browse files
Options
Downloads
Patches
Plain Diff
Make the max number of old descriptors to hold rise with the number of authorities.
svn:r6254
parent
90a40e0e
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/or/routerlist.c
+16
-7
16 additions, 7 deletions
src/or/routerlist.c
with
16 additions
and
7 deletions
src/or/routerlist.c
+
16
−
7
View file @
685bceed
...
...
@@ -37,8 +37,6 @@ static int have_tried_downloading_all_statuses(void);
static
routerstatus_t
*
networkstatus_find_entry
(
networkstatus_t
*
ns
,
const
char
*
digest
);
#define MAX_DESCRIPTORS_PER_ROUTER 5
/****************************************************************************/
/** Global list of a trusted_dir_server_t object for each trusted directory
...
...
@@ -1171,6 +1169,17 @@ dump_routerlist_mem_usage(int severity)
smartlist_len
(
routerlist
->
old_routers
),
U64_PRINTF_ARG
(
olddescs
));
}
/** Return the greatest number of routerdescs we'll hold for any given router.
*/
static
int
max_descriptors_per_router
(
void
)
{
int
n_authorities
=
0
;
if
(
trusted_dir_servers
)
n_authorities
=
smartlist_len
(
trusted_dir_servers
);
return
(
n_authorities
<
5
)
?
5
:
n_authorities
;
}
/** Return non-zero if we have a lot of extra descriptors in our
* routerlist, and should get rid of some of them. Else return 0.
*
...
...
@@ -1183,7 +1192,7 @@ static INLINE int
routerlist_is_overfull
(
routerlist_t
*
rl
)
{
return
smartlist_len
(
rl
->
old_routers
)
>
smartlist_len
(
rl
->
routers
)
*
(
MAX_DESCRIPTORS_PER_ROUTER
+
1
);
smartlist_len
(
rl
->
routers
)
*
(
max_descriptors_per_router
()
+
1
);
}
static
INLINE
int
...
...
@@ -1657,7 +1666,7 @@ _compare_duration_idx(const void *_d1, const void *_d2)
/** The range <b>lo</b> through <b>hi</b> inclusive of routerlist->old_routers
* must contain routerinfo_t with the same identity and with publication time
* in ascending order. Remove members from this range until there are no more
* than
MAX_DESCRIPTORS_PER_ROUTER
remaining. Start by removing the oldest
* than
max_descriptors_per_router()
remaining. Start by removing the oldest
* members from before <b>cutoff</b>, then remove members which were current
* for the lowest amount of time. The order of members of old_routers at
* indices <b>lo</b> or higher may be changed.
...
...
@@ -1683,7 +1692,7 @@ routerlist_remove_old_cached_routers_with_id(time_t cutoff, int lo, int hi,
#endif
/* Check whether we need to do anything at all. */
n_extra
=
n
-
MAX_DESCRIPTORS_PER_ROUTER
;
n_extra
=
n
-
max_descriptors_per_router
()
;
if
(
n_extra
<=
0
)
return
;
...
...
@@ -1796,10 +1805,10 @@ routerlist_remove_old_routers(void)
* members. (We'd keep all the members if we could, but we'd like to save
* space.) First, check whether we have too many router descriptors, total.
* We're okay with having too many for some given router, so long as the
* total number doesn't approach
MAX_DESCRIPTORS_PER_ROUTER
*len(router).
* total number doesn't approach
max_descriptors_per_router()
*len(router).
*/
if
(
smartlist_len
(
routerlist
->
old_routers
)
<
smartlist_len
(
routerlist
->
routers
)
*
(
MAX_DESCRIPTORS_PER_ROUTER
-
1
))
smartlist_len
(
routerlist
->
routers
)
*
(
max_descriptors_per_router
()
-
1
))
goto
done
;
smartlist_sort
(
routerlist
->
old_routers
,
_compare_old_routers_by_identity
);
...
...
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