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/circuituse.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/circuituse.c')
-rw-r--r-- | src/or/circuituse.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/or/circuituse.c b/src/or/circuituse.c index e3b63b6663..d19a415c9a 100644 --- a/src/or/circuituse.c +++ b/src/or/circuituse.c @@ -333,7 +333,7 @@ circuit_stream_is_being_handled(connection_t *conn, uint16_t port, int min) return 0; } -/** Don't keep more than 10 unused open circuits around. */ +/** Don't keep more than this many unused open circuits around. */ #define MAX_UNUSED_OPEN_CIRCUITS 12 /** Figure out how many circuits we have open that are clean. Make @@ -547,6 +547,9 @@ circuit_about_to_close_connection(connection_t *conn) } /* end switch */ } +/** How old do we let an unused circuit get before expiring it? */ +#define CIRCUIT_UNUSED_CIRC_TIMEOUT (60*60) + /** Find each circuit that has been dirty for too long, and has * no streams on it: mark it for close. */ @@ -576,7 +579,6 @@ circuit_expire_old_circuits(void) } else if (!circ->timestamp_dirty && CIRCUIT_IS_ORIGIN(circ) && circ->state == CIRCUIT_STATE_OPEN && circ->purpose == CIRCUIT_PURPOSE_C_GENERAL) { -#define CIRCUIT_UNUSED_CIRC_TIMEOUT 3600 /* an hour */ if (circ->timestamp_created + CIRCUIT_UNUSED_CIRC_TIMEOUT < now) { log_debug(LD_CIRC, "Closing circuit that has been unused for %d seconds.", |