diff options
author | Nick Mathewson <nickm@torproject.org> | 2013-01-03 13:26:59 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2013-01-03 13:26:59 -0500 |
commit | 677d18278e5b27a43f3f56906d97a9575d26c6f4 (patch) | |
tree | db322a2f85308254d3e9e4411b7563e107b7f28a /src | |
parent | 30e139389bd8301f62ee24481d0f5484544fc5de (diff) | |
download | tor-677d18278e5b27a43f3f56906d97a9575d26c6f4.tar tor-677d18278e5b27a43f3f56906d97a9575d26c6f4.tar.gz |
Better handling (I think) for onionskin timing w jumpy clocks
The fix: Instead of clipping huge/negative times, ignore them as
probably invalid.
Diffstat (limited to 'src')
-rw-r--r-- | src/or/cpuworker.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/src/or/cpuworker.c b/src/or/cpuworker.c index 42f7b9572..52a0117d3 100644 --- a/src/or/cpuworker.c +++ b/src/or/cpuworker.c @@ -320,19 +320,18 @@ connection_cpu_process_inbuf(connection_t *conn) tor_gettimeofday(&tv_end); timersub(&tv_end, &rpl.started_at, &tv_diff); usec_roundtrip = ((int64_t)tv_diff.tv_sec)*1000000 + tv_diff.tv_usec; - if (usec_roundtrip < 0 || - usec_roundtrip > MAX_BELIEVABLE_ONIONSKIN_DELAY) { - usec_roundtrip = MAX_BELIEVABLE_ONIONSKIN_DELAY; - } - ++onionskins_n_processed[rpl.handshake_type]; - onionskins_usec_internal[rpl.handshake_type] += rpl.n_usec; - onionskins_usec_roundtrip[rpl.handshake_type] += usec_roundtrip; - if (onionskins_n_processed[rpl.handshake_type] >= 500000) { - /* Scale down every 500000 handshakes. On a busy server, that's - * less impressive than it sounds. */ - onionskins_n_processed[rpl.handshake_type] /= 2; - onionskins_usec_internal[rpl.handshake_type] /= 2; - onionskins_usec_roundtrip[rpl.handshake_type] /= 2; + if (usec_roundtrip >= 0 && + usec_roundtrip < MAX_BELIEVABLE_ONIONSKIN_DELAY) { + ++onionskins_n_processed[rpl.handshake_type]; + onionskins_usec_internal[rpl.handshake_type] += rpl.n_usec; + onionskins_usec_roundtrip[rpl.handshake_type] += usec_roundtrip; + if (onionskins_n_processed[rpl.handshake_type] >= 500000) { + /* Scale down every 500000 handshakes. On a busy server, that's + * less impressive than it sounds. */ + onionskins_n_processed[rpl.handshake_type] /= 2; + onionskins_usec_internal[rpl.handshake_type] /= 2; + onionskins_usec_roundtrip[rpl.handshake_type] /= 2; + } } } /* parse out the circ it was talking about */ |