diff options
author | Nick Mathewson <nickm@torproject.org> | 2013-06-13 12:42:49 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2013-06-13 12:42:49 -0400 |
commit | 45424b2ca1638d5b3d147bb518c092a41028e259 (patch) | |
tree | 867615adfef97807842059ffb2fade77c08dc60b /src/or/dirvote.c | |
parent | 4b781e24fb920ad4cd2268b609e4b4b0bd5adb7d (diff) | |
parent | c132427db4f207a32e4abaae0e070840e5e2b808 (diff) | |
download | tor-45424b2ca1638d5b3d147bb518c092a41028e259.tar tor-45424b2ca1638d5b3d147bb518c092a41028e259.tar.gz |
Merge remote-tracking branch 'linus/bug8532'
Diffstat (limited to 'src/or/dirvote.c')
-rw-r--r-- | src/or/dirvote.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/or/dirvote.c b/src/or/dirvote.c index 0c386e604..4f0ab6833 100644 --- a/src/or/dirvote.c +++ b/src/or/dirvote.c @@ -2523,12 +2523,13 @@ dirvote_get_preferred_voting_intervals(vote_timing_t *timing_out) timing_out->dist_delay = options->V3AuthDistDelay; } -/** Return the start of the next interval of size <b>interval</b> (in seconds) - * after <b>now</b>. Midnight always starts a fresh interval, and if the last - * interval of a day would be truncated to less than half its size, it is - * rolled into the previous interval. */ +/** Return the start of the next interval of size <b>interval</b> (in + * seconds) after <b>now</b>, plus <b>offset</b>. Midnight always + * starts a fresh interval, and if the last interval of a day would be + * truncated to less than half its size, it is rolled into the + * previous interval. */ time_t -dirvote_get_start_of_next_interval(time_t now, int interval) +dirvote_get_start_of_next_interval(time_t now, int interval, int offset) { struct tm tm; time_t midnight_today=0; @@ -2556,6 +2557,10 @@ dirvote_get_start_of_next_interval(time_t now, int interval) if (next + interval/2 > midnight_tomorrow) next = midnight_tomorrow; + next += offset; + if (next - interval > now) + next -= interval; + return next; } @@ -2619,8 +2624,10 @@ dirvote_recalculate_timing(const or_options_t *options, time_t now) vote_delay = dist_delay = interval / 4; start = voting_schedule.interval_starts = - dirvote_get_start_of_next_interval(now,interval); - end = dirvote_get_start_of_next_interval(start+1, interval); + dirvote_get_start_of_next_interval(now,interval, + options->TestingV3AuthVotingStartOffset); + end = dirvote_get_start_of_next_interval(start+1, interval, + options->TestingV3AuthVotingStartOffset); tor_assert(end > start); |