diff options
author | Nick Mathewson <nickm@torproject.org> | 2006-03-12 22:48:18 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2006-03-12 22:48:18 +0000 |
commit | 474c60b7433da2302c35832571f41867714d8f65 (patch) | |
tree | 630b53f7fdd65de04d7a8735262221f5d419bf4a /src/or/config.c | |
parent | b67a5ba49801a0a4e190036a30cd0b3d622de9ef (diff) | |
download | tor-474c60b7433da2302c35832571f41867714d8f65.tar.gz tor-474c60b7433da2302c35832571f41867714d8f65.zip |
Cleanup on time-relaqted constants. New conventions:
1) Surround all constants by (parens), whether we'll be using them
in a denominator or not.
2) Express all time periods as products (24*60*60), not as multiplied-out
constants (86400).
3) Comments like "(60*60) /* one hour */" are as pointless as comments
like "c = a + b; /* set c to the sum of a and b */". Remove them.
4) All time periods should be #defined constants, not given inline.
5) All time periods should have doxygen comments.
6) All time periods, unless specified, are in seconds. It's not necessary
to say so.
To summarize, the old (lack of) style would allow:
#define FOO_RETRY_INTERVAL 60*60 /* one hour (seconds) */
next_try = now + 3600;
The new style is:
/** How often do we reattempt foo? */
#define FOO_RETRY_INTERVAL (60*60)
next_try = now + RETRY_INTERVAL;
svn:r6142
Diffstat (limited to 'src/or/config.c')
-rw-r--r-- | src/or/config.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/src/or/config.c b/src/or/config.c index 39adec0a5c..e6c3265213 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -1952,6 +1952,24 @@ fascist_firewall_allows_address_dir(uint32_t addr, uint16_t port) reachable_dir_addr_policy); } +/** Lowest allowable value for DirFetchPeriod; if this is too low, clients can + * overload the directory system. */ +#define MIN_DIR_FETCH_PERIOD (10*60) +/** Lowest allowable value for RendPostPeriod; if this is too low, hidden + * services can overload the directory system. */ +#define MIN_REND_POST_PERIOD (5*60) +/** Lowest allowable value for StatusFetchPeriod; if this is too low, clients + * can overload the directory system. */ +#define MIN_STATUS_FETCH_PERIOD (5*60) + +/** Highest allowable value for DirFetchPeriod, StatusFetchPeriod, and + * RendPostPeriod. */ +#define MAX_DIR_PERIOD (MIN_ONION_KEY_LIFETIME/2) +/** Highest allowable value for DirFetchPeriod for directory caches. */ +#define MAX_CACHE_DIR_FETCH_PERIOD (60*60) +/** Highest allowable value for StatusFetchPeriod for directory caches. */ +#define MAX_CACHE_STATUS_FETCH_PERIOD (15*60) + /** Return 0 if every setting in <b>options</b> is reasonable. Else * warn and return -1. Should have no side effects, except for * normalizing the contents of <b>options</b>. @@ -2257,14 +2275,6 @@ options_validate(or_options_t *old_options, or_options_t *options, (options->PathlenCoinWeight < 0.0 || options->PathlenCoinWeight >= 1.0)) REJECT("PathlenCoinWeight option must be >=0.0 and <1.0."); -#define MIN_DIR_FETCH_PERIOD 600 -#define MIN_REND_POST_PERIOD 300 -#define MIN_STATUS_FETCH_PERIOD 60 - -#define MAX_DIR_PERIOD (MIN_ONION_KEY_LIFETIME/2) -#define MAX_CACHE_DIR_FETCH_PERIOD 3600 -#define MAX_CACHE_STATUS_FETCH_PERIOD 900 - if (options->DirFetchPeriod && options->DirFetchPeriod < MIN_DIR_FETCH_PERIOD) { log(LOG_WARN, LD_CONFIG, |