summaryrefslogtreecommitdiff
path: root/src/or/consdiffmgr.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2017-07-12 13:15:16 -0400
committerNick Mathewson <nickm@torproject.org>2017-07-12 13:15:16 -0400
commitabb9a5bdda9bde028704c01c47191c64cfa088c8 (patch)
tree23bd8a5f3d682e02a2a0ac57ea82538d9f15cee2 /src/or/consdiffmgr.c
parent5636b160d42e344f936f881992c19b3c27f60a2c (diff)
downloadtor-abb9a5bdda9bde028704c01c47191c64cfa088c8.tar.gz
tor-abb9a5bdda9bde028704c01c47191c64cfa088c8.zip
New configuration option MaxConsensusAgeForDiffs
Relay operators (especially bridge operators) can use this to lower or raise the number of consensuses that they're willing to hold for diff generation purposes. This enables a workaround for bug 22883.
Diffstat (limited to 'src/or/consdiffmgr.c')
-rw-r--r--src/or/consdiffmgr.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/or/consdiffmgr.c b/src/or/consdiffmgr.c
index 638fcd6794..a3ffed10db 100644
--- a/src/or/consdiffmgr.c
+++ b/src/or/consdiffmgr.c
@@ -14,6 +14,7 @@
#define CONSDIFFMGR_PRIVATE
#include "or.h"
+#include "config.h"
#include "conscache.h"
#include "consdiff.h"
#include "consdiffmgr.h"
@@ -462,12 +463,22 @@ cdm_cache_lookup_consensus(consensus_flavor_t flavor, time_t valid_after)
static int32_t
get_max_age_to_cache(void)
{
- /* The parameter is in hours. */
const int32_t DEFAULT_MAX_AGE_TO_CACHE = 8192;
const int32_t MIN_MAX_AGE_TO_CACHE = 0;
const int32_t MAX_MAX_AGE_TO_CACHE = 8192;
const char MAX_AGE_TO_CACHE_NAME[] = "max-consensus-age-to-cache-for-diff";
+ const or_options_t *options = get_options();
+
+ if (options->MaxConsensusAgeForDiffs) {
+ const int v = options->MaxConsensusAgeForDiffs;
+ if (v >= MAX_MAX_AGE_TO_CACHE * 3600)
+ return MAX_MAX_AGE_TO_CACHE;
+ else
+ return v;
+ }
+
+ /* The parameter is in hours, so we multiply */
return 3600 * networkstatus_get_param(NULL,
MAX_AGE_TO_CACHE_NAME,
DEFAULT_MAX_AGE_TO_CACHE,