diff options
author | Nick Mathewson <nickm@torproject.org> | 2004-03-21 03:03:10 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2004-03-21 03:03:10 +0000 |
commit | b7c2b18bd696f79e6866ae70c58373dfbedf91f0 (patch) | |
tree | 4674f7f0ab23e4b4d4c148c832cdf1a76092fadc /src/or/circuit.c | |
parent | 0d8feba6d8225f012cadbfccb001236260f83bf5 (diff) | |
download | tor-b7c2b18bd696f79e6866ae70c58373dfbedf91f0.tar tor-b7c2b18bd696f79e6866ae70c58373dfbedf91f0.tar.gz |
Add a RunTesting option to try to learn link state by creating test circuits, even when SocksPort is off.
svn:r1327
Diffstat (limited to 'src/or/circuit.c')
-rw-r--r-- | src/or/circuit.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/or/circuit.c b/src/or/circuit.c index 45b10ee25..c4f51e79a 100644 --- a/src/or/circuit.c +++ b/src/or/circuit.c @@ -907,6 +907,9 @@ void circuit_dump_by_conn(connection_t *conn, int severity) { } } +/* Expire unused testing circuits after 10 minutes. */ +#define TESTING_CIRCUIT_MAX_AGE 600 + void circuit_expire_unused_circuits(void) { circuit_t *circ, *tmpcirc; time_t now = time(NULL); @@ -915,9 +918,18 @@ void circuit_expire_unused_circuits(void) { while(circ) { tmpcirc = circ; circ = circ->next; - if(tmpcirc->timestamp_dirty && - tmpcirc->timestamp_dirty + options.NewCircuitPeriod < now && - !tmpcirc->p_conn && !tmpcirc->p_streams && !tmpcirc->marked_for_close) { + /* If the circuit has been dirty for too long, and there are no streams + * on it, mark it for close. + * If we are creating test circuits, and the circuit is old, and has + * no streams, shut it down even if it isn't dirty. + */ + if(((tmpcirc->timestamp_dirty && + tmpcirc->timestamp_dirty + options.NewCircuitPeriod < now) || + (options.RunTesting && + tmpcirc->timestamp_created + TESTING_CIRCUIT_MAX_AGE < now)) + && !tmpcirc->p_conn + && !tmpcirc->p_streams + && !tmpcirc->marked_for_close) { log_fn(LOG_DEBUG,"Closing n_circ_id %d",tmpcirc->n_circ_id); circuit_mark_for_close(tmpcirc); } @@ -932,7 +944,7 @@ static int n_circuit_failures = 0; /* Return -1 if you aren't going to try to make a circuit, 0 if you did try. */ int circuit_launch_new(void) { - if(!options.SocksPort) /* we're not an application proxy. no need for circuits. */ + if(!(options.SocksPort||options.RunTesting)) /* no need for circuits. */ return -1; if(n_circuit_failures > 5) { /* too many failed circs in a row. don't try. */ |