diff options
author | Nick Mathewson <nickm@torproject.org> | 2010-08-17 12:07:19 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2010-08-17 12:07:19 -0400 |
commit | 5ffe105598135a92777d78cc82399fa281c52c5f (patch) | |
tree | 72f07c2d9649154a962529a94f2b651e499fc35b | |
parent | 2ede14c2ca65df89b5918fdf38b223aa675a98bd (diff) | |
parent | fc66a2ad1bf1e653cae47eb54fc6324d29d5916e (diff) | |
download | tor-5ffe105598135a92777d78cc82399fa281c52c5f.tar.gz tor-5ffe105598135a92777d78cc82399fa281c52c5f.zip |
Merge branch 'maint-0.2.1'
Resolved conflict in
src/or/networkstatus.c
-rw-r--r-- | changes/bug1141 | 5 | ||||
-rw-r--r-- | src/or/networkstatus.c | 19 |
2 files changed, 20 insertions, 4 deletions
diff --git a/changes/bug1141 b/changes/bug1141 new file mode 100644 index 0000000000..9975e418d6 --- /dev/null +++ b/changes/bug1141 @@ -0,0 +1,5 @@ + o Minor bugfixes: + - Fix an assertion failure that could occur in caches or bridge users + when using a very short voting interval on a testing network. + Diagnosed by Robert Hogan. Fixes bug 1141; bugfix on 0.2.0.8-alpha. + diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c index 0ec69cb29b..c0a3a28e4b 100644 --- a/src/or/networkstatus.c +++ b/src/or/networkstatus.c @@ -1230,14 +1230,26 @@ update_consensus_networkstatus_fetch_time(time_t now) if (c) { long dl_interval; long interval = c->fresh_until - c->valid_after; + long min_sec_before_caching = CONSENSUS_MIN_SECONDS_BEFORE_CACHING; time_t start; + + if (min_sec_before_caching > interval/16) { + /* Usually we allow 2-minutes slop factor in case clocks get + desynchronized a little. If we're on a private network with + a crazy-fast voting interval, though, 2 minutes may be too + much. */ + min_sec_before_caching = interval/16; + } + if (directory_fetches_dir_info_early(options)) { /* We want to cache the next one at some point after this one * is no longer fresh... */ - start = c->fresh_until + CONSENSUS_MIN_SECONDS_BEFORE_CACHING; + start = c->fresh_until + min_sec_before_caching; /* Some clients may need the consensus sooner than others. */ if (options->FetchDirInfoExtraEarly) { dl_interval = 60; + if (min_sec_before_caching + dl_interval > interval) + dl_interval = interval/2; } else { /* But only in the first half-interval after that. */ dl_interval = interval/2; @@ -1253,10 +1265,9 @@ update_consensus_networkstatus_fetch_time(time_t now) * to choose the rest of the interval *after* them. */ if (directory_fetches_dir_info_later(options)) { /* Give all the *clients* enough time to download the consensus. */ - start = start + dl_interval + CONSENSUS_MIN_SECONDS_BEFORE_CACHING; + start = start + dl_interval + min_sec_before_caching; /* But try to get it before ours actually expires. */ - dl_interval = (c->valid_until - start) - - CONSENSUS_MIN_SECONDS_BEFORE_CACHING; + dl_interval = (c->valid_until - start) - min_sec_before_caching; } } if (dl_interval < 1) |