When using exponential backoff in test networks, use a lower exponent

Lower exponents mean that delays do not vary as much. This helps test
networks bootstrap consistently.

Bugfix on 20499.
This commit is contained in:
teor 2016-11-08 16:39:36 +11:00
parent 3dfecffa7d
commit 38e3f91c63
No known key found for this signature in database
GPG Key ID: 450CBA7F968F094B
2 changed files with 11 additions and 1 deletions

5
changes/bug20597 Normal file
View File

@ -0,0 +1,5 @@
o Minor bugfixes (test networks, exponential backoff):
- When using exponential backoff in test networks, use a lower exponent,
so the delays do not vary as much. This helps test networks bootstrap
consistently. Fixes bug 20597; bugfix on 20499; not in any released
version of tor.

View File

@ -3796,7 +3796,12 @@ next_random_exponential_delay(int delay, int max_delay)
/* How much are we willing to add to the delay? */
int max_increment;
const int multiplier = 3; /* no more than quadruple the previous delay */
int multiplier = 3; /* no more than quadruple the previous delay */
if (get_options()->TestingTorNetwork) {
/* Decrease the multiplier in testing networks. This reduces the variance,
* so that bootstrap is more reliable. */
multiplier = 2; /* no more than triple the previous delay */
}
if (delay && delay < (INT_MAX-1) / multiplier) {
max_increment = delay * multiplier;