aboutsummaryrefslogtreecommitdiff
path: root/src/or
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2010-06-29 18:57:59 -0400
committerNick Mathewson <nickm@torproject.org>2010-06-29 18:57:59 -0400
commit485cab869d292becb62a43b2e33a399ebc671303 (patch)
tree7052a37a6c36d67cb7d48524766103890545e487 /src/or
parentbea55766af461e4ca78a4919912f3aa9de978bdc (diff)
parentb111a7cd9c5e09bedf57a67f9044a2974222cd11 (diff)
downloadtor-485cab869d292becb62a43b2e33a399ebc671303.tar
tor-485cab869d292becb62a43b2e33a399ebc671303.tar.gz
Merge remote branch 'public/rand_double2'
Diffstat (limited to 'src/or')
-rw-r--r--src/or/circuitbuild.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index 1e51ffbe7..1d654f04c 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -815,18 +815,20 @@ build_time_t
circuit_build_times_generate_sample(circuit_build_times_t *cbt,
double q_lo, double q_hi)
{
- uint64_t r = crypto_rand_uint64(UINT64_MAX-1);
+ double randval = crypto_rand_double();
build_time_t ret;
double u;
/* Generate between [q_lo, q_hi) */
+ /*XXXX This is what nextafter is supposed to be for; we should use it on the
+ * platforms that support it. */
q_hi -= 1.0/(INT32_MAX);
tor_assert(q_lo >= 0);
tor_assert(q_hi < 1);
tor_assert(q_lo < q_hi);
- u = q_lo + ((q_hi-q_lo)*r)/(1.0*UINT64_MAX);
+ u = q_lo + (q_hi-q_lo)*randval;
tor_assert(0 <= u && u < 1.0);
/* circuit_build_times_calculate_timeout returns <= INT32_MAX */