diff options
author | Mike Perry <mikeperry-git@fscked.org> | 2010-05-07 15:42:57 -0700 |
---|---|---|
committer | Mike Perry <mikeperry-git@fscked.org> | 2010-05-10 13:11:46 -0700 |
commit | 728e946efd87d5cd0a9ff073eeeb7b4fe9c3c0db (patch) | |
tree | 29c64c0dc8fd688ee9a67c8f1622eb1cb608360c /src/or/circuituse.c | |
parent | e40e35507e91e8724a37ef2e6bf5828025f2dbe5 (diff) | |
download | tor-728e946efd87d5cd0a9ff073eeeb7b4fe9c3c0db.tar.gz tor-728e946efd87d5cd0a9ff073eeeb7b4fe9c3c0db.zip |
Bug 1245: Ignore negative and large timeouts.
This should prevent some asserts and storage of incorrect build times
for the cases where Tor is suspended during a circuit construction, or
just after completing a circuit. The idea is that if the circuit
build time is much greater than we would have cut it off at, we probably
had a suspend event along this codepath, and we should discard the
value.
Diffstat (limited to 'src/or/circuituse.c')
-rw-r--r-- | src/or/circuituse.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/or/circuituse.c b/src/or/circuituse.c index 7e47e60559..e7d10a22f2 100644 --- a/src/or/circuituse.c +++ b/src/or/circuituse.c @@ -350,9 +350,20 @@ circuit_expire_building(time_t now) } else { /* circuit not open, consider recording failure as timeout */ int first_hop_succeeded = TO_ORIGIN_CIRCUIT(victim)->cpath && TO_ORIGIN_CIRCUIT(victim)->cpath->state == CPATH_STATE_OPEN; - if (circuit_build_times_add_timeout(&circ_times, first_hop_succeeded, - victim->timestamp_created)) + /* + * If the circuit build time is much greater than we would have cut + * it off at, we probably had a suspend event along this codepath, + * and we should discard the value. + */ + if (now - victim->timestamp_created > (2*circ_times.timeout_ms)/1000+1) { + log_notice(LD_CIRC, + "Extremely large value for circuit build timeout: %ld. " + "Assuming clock jump.", now - victim->timestamp_created); + } else if (circuit_build_times_add_timeout(&circ_times, + first_hop_succeeded, + victim->timestamp_created)) { circuit_build_times_set_timeout(&circ_times); + } } if (victim->n_conn) |