summaryrefslogtreecommitdiff
path: root/changes/bug6538
AgeCommit message (Collapse)Author
2012-08-09Refactor the core of choosing by weights into a functionNick Mathewson
This eliminates duplicated code, and lets us test a hairy piece of functionality.
2012-08-09Remove remaining timing-dependency in choosing nodes by bandwidthNick Mathewson
The old approach, because of its "tmp >= rand_bw && !i_has_been_chosen" check, would run through the second part of the loop slightly slower than the first part. Now, we remove i_has_been_chosen, and instead set rand_bw = UINT64_MAX, so that every instance of the loop will do exactly the same amount of work regardless of the initial value of rand_bw. Fix for bug 6538.
2012-08-09Change smartlist_choose_node_by_bandwidth to avoid doubleNick Mathewson
This should make our preferred solution to #6538 easier to implement, avoid a bunch of potential nastiness with excessive int-vs-double math, and generally make the code there a little less scary. "But wait!" you say. "Is it really safe to do this? Won't the results come out differently?" Yes, but not much. We now round every weighted bandwidth to the nearest byte before computing on it. This will make every node that had a fractional part of its weighted bandwidth before either slighty more likely or slightly less likely. Further, the rand_bw value was only ever set with integer precision, so it can't accurately sample routers with tiny fractional bandwidth values anyway. Finally, doing repeated double-vs-uint64 comparisons is just plain sad; it will involve an implicit cast to double, which is never a fun thing.