aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2013-02-08 16:31:46 -0500
committerNick Mathewson <nickm@torproject.org>2013-02-08 16:31:46 -0500
commit018fe7d11e148538f29418c5e2ff91ff314c3a11 (patch)
treed21db557192b96ad80160e31b3474bf4708680de
parent8cdd8b83539e57fb1891cce5b527dda335ab1452 (diff)
downloadtor-018fe7d11e148538f29418c5e2ff91ff314c3a11.tar
tor-018fe7d11e148538f29418c5e2ff91ff314c3a11.tar.gz
Improve comment about our random stream choice algorithm
-rw-r--r--src/or/relay.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/or/relay.c b/src/or/relay.c
index cbb2aca10..3da426e6b 100644
--- a/src/or/relay.c
+++ b/src/or/relay.c
@@ -1795,9 +1795,17 @@ circuit_resume_edge_reading_helper(edge_connection_t *first_conn,
num_streams++;
if (tor_weak_random_one_in_n(&stream_choice_rng, num_streams)) {
chosen_stream = conn;
- /* Invariant: chosen_stream has been chosen uniformly at random from
- * among the first num_streams streams on first_conn. */
}
+ /* Invariant: chosen_stream has been chosen uniformly at random from
+ * among the first num_streams streams on first_conn.
+ *
+ * (Note that we iterate over every stream on the circuit, so that after
+ * we've considered the first stream, we've chosen it with P=1; and
+ * after we consider the second stream, we've switched to it with P=1/2
+ * and stayed with the first stream with P=1/2; and after we've
+ * considered the third stream, we've switched to it with P=1/3 and
+ * remained with one of the first two streams with P=(2/3), giving each
+ * one P=(1/2)(2/3) )=(1/3).) */
}
}