Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Tor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
The Tor Project
Core
Tor
Commits
b3ec39af
Commit
b3ec39af
authored
15 years ago
by
Nick Mathewson
Browse files
Options
Downloads
Plain Diff
Merge remote branch 'mikeperry/bwweight-smartlistfix'
parents
f3003d58
2b5e1d36
No related branches found
Branches containing commit
No related tags found
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
+23
-0
23 additions, 0 deletions
src/or/routerlist.c
with
23 additions
and
0 deletions
src/or/routerlist.c
+
23
−
0
View file @
b3ec39af
...
...
@@ -1574,6 +1574,13 @@ smartlist_choose_by_bandwidth_weights(smartlist_t *sl,
rule
==
WEIGHT_FOR_MID
||
rule
==
WEIGHT_FOR_DIR
);
if
(
smartlist_len
(
sl
)
==
0
)
{
log_info
(
LD_CIRC
,
"Empty routerlist passed in to consensus weight node "
"selection for rule %d"
,
rule
);
return
NULL
;
}
weight_scale
=
networkstatus_get_param
(
NULL
,
"bwweightscale"
,
BW_WEIGHT_SCALE
);
...
...
@@ -1692,6 +1699,15 @@ smartlist_choose_by_bandwidth_weights(smartlist_t *sl,
"Wg=%lf Wm=%lf We=%lf Wd=%lf with total bw %lf"
,
rule
,
Wg
,
Wm
,
We
,
Wd
,
weighted_bw
);
/* If there is no bandwidth, choose at random */
if
(
DBL_TO_U64
(
weighted_bw
)
==
0
)
{
log_warn
(
LD_CIRC
,
"Weighted bandwidth is %lf in node selection for rule %d"
,
weighted_bw
,
rule
);
tor_free
(
bandwidths
);
return
smartlist_choose
(
sl
);
}
rand_bw
=
crypto_rand_uint64
(
DBL_TO_U64
(
weighted_bw
));
rand_bw
++
;
/* crypto_rand_uint64() counts from 0, and we need to count
* from 1 below. See bug 1203 for details. */
...
...
@@ -1765,6 +1781,13 @@ smartlist_choose_by_bandwidth(smartlist_t *sl, bandwidth_weight_rule_t rule,
rule
==
WEIGHT_FOR_EXIT
||
rule
==
WEIGHT_FOR_GUARD
);
if
(
smartlist_len
(
sl
)
==
0
)
{
log_info
(
LD_CIRC
,
"Empty routerlist passed in to old node selection for rule %d"
,
rule
);
return
NULL
;
}
/* First count the total bandwidth weight, and make a list
* of each value. <0 means "unknown; no routerinfo." We use the
* bits of negative values to remember whether the router was fast (-x)&1
...
...
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