summaryrefslogtreecommitdiff
path: root/src/or/directory.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-01-25 15:52:33 -0500
committerNick Mathewson <nickm@torproject.org>2018-01-25 15:52:33 -0500
commitbf74194f57398fcc19f3123740014ca38ab61ec2 (patch)
tree74261b0eb98348d5e844e095cec3f011f4be6909 /src/or/directory.c
parente0049ef022b8bf9b808a9074820bb2a33f92ac1b (diff)
downloadtor-bf74194f57398fcc19f3123740014ca38ab61ec2.tar.gz
tor-bf74194f57398fcc19f3123740014ca38ab61ec2.zip
fixup! Remove the old ("deterministic") download schedule.
Un-indent a block. I'm doing this as a separate fixup commit to make review simpler.
Diffstat (limited to 'src/or/directory.c')
-rw-r--r--src/or/directory.c47
1 files changed, 22 insertions, 25 deletions
diff --git a/src/or/directory.c b/src/or/directory.c
index a2e514e796..3d5321157e 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -5471,36 +5471,33 @@ download_status_schedule_get_delay(download_status_t *dls,
? dls->n_download_attempts
: dls->n_download_failures);
- { // XXXX 23814 unindent.
-
- /* Check if we missed a reset somehow */
- IF_BUG_ONCE(dls->last_backoff_position > dls_schedule_position) {
- dls->last_backoff_position = 0;
- dls->last_delay_used = 0;
- }
+ /* Check if we missed a reset somehow */
+ IF_BUG_ONCE(dls->last_backoff_position > dls_schedule_position) {
+ dls->last_backoff_position = 0;
+ dls->last_delay_used = 0;
+ }
- if (dls_schedule_position > 0) {
- delay = dls->last_delay_used;
+ if (dls_schedule_position > 0) {
+ delay = dls->last_delay_used;
- while (dls->last_backoff_position < dls_schedule_position) {
- /* Do one increment step */
- delay = next_random_exponential_delay(delay, min_delay, max_delay);
- /* Update our position */
- ++(dls->last_backoff_position);
- }
- } else {
- /* If we're just starting out, use the minimum delay */
- delay = min_delay;
+ while (dls->last_backoff_position < dls_schedule_position) {
+ /* Do one increment step */
+ delay = next_random_exponential_delay(delay, min_delay, max_delay);
+ /* Update our position */
+ ++(dls->last_backoff_position);
}
+ } else {
+ /* If we're just starting out, use the minimum delay */
+ delay = min_delay;
+ }
- /* Clamp it within min/max if we have them */
- if (min_delay >= 0 && delay < min_delay) delay = min_delay;
- if (max_delay != INT_MAX && delay > max_delay) delay = max_delay;
+ /* Clamp it within min/max if we have them */
+ if (min_delay >= 0 && delay < min_delay) delay = min_delay;
+ if (max_delay != INT_MAX && delay > max_delay) delay = max_delay;
- /* Store it for next time */
- dls->last_backoff_position = dls_schedule_position;
- dls->last_delay_used = delay;
- }
+ /* Store it for next time */
+ dls->last_backoff_position = dls_schedule_position;
+ dls->last_delay_used = delay;
/* A negative delay makes no sense. Knowing that delay is
* non-negative allows us to safely do the wrapping check below. */