diff options
author | Nick Mathewson <nickm@torproject.org> | 2017-07-13 16:55:06 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-07-13 16:55:06 -0400 |
commit | 66a564fad8a99a21bd6cda6a70982858376b78e9 (patch) | |
tree | 54d124cdfe5e6e3b92b22e61c3dde02440888361 /src | |
parent | ec29cae8d7e97d652a87d753d93e4289e5a0ed26 (diff) | |
parent | 66258f8878abe6323c56bcf0b20796e1c43d66fc (diff) | |
download | tor-66a564fad8a99a21bd6cda6a70982858376b78e9.tar.gz tor-66a564fad8a99a21bd6cda6a70982858376b78e9.zip |
Merge branch 'maint-0.3.1'
Diffstat (limited to 'src')
-rw-r--r-- | src/or/config.c | 1 | ||||
-rw-r--r-- | src/or/consdiffmgr.c | 13 | ||||
-rw-r--r-- | src/or/or.h | 5 |
3 files changed, 18 insertions, 1 deletions
diff --git a/src/or/config.c b/src/or/config.c index 5b5bb9049b..6c0856b141 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -393,6 +393,7 @@ static config_var_t option_vars_[] = { V(MaxAdvertisedBandwidth, MEMUNIT, "1 GB"), V(MaxCircuitDirtiness, INTERVAL, "10 minutes"), V(MaxClientCircuitsPending, UINT, "32"), + V(MaxConsensusAgeForDiffs, INTERVAL, "0 seconds"), VAR("MaxMemInQueues", MEMUNIT, MaxMemInQueues_raw, "0"), OBSOLETE("MaxOnionsPending"), V(MaxOnionQueueDelay, MSEC_INTERVAL, "1750 msec"), 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, diff --git a/src/or/or.h b/src/or/or.h index 996a7700b5..f6c42b7a99 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -4579,6 +4579,11 @@ typedef struct { /** Bool (default: 0): Tells if a %include was used on torrc */ int IncludeUsed; + + /** The seconds after expiration which we as a relay should keep old + * consensuses around so that we can generate diffs from them. If 0, + * use the default. */ + int MaxConsensusAgeForDiffs; } or_options_t; /** Persistent state for an onion router, as saved to disk. */ |