diff options
author | Roger Dingledine <arma@torproject.org> | 2005-03-19 23:58:42 +0000 |
---|---|---|
committer | Roger Dingledine <arma@torproject.org> | 2005-03-19 23:58:42 +0000 |
commit | 4a497e503077826228df667083548d06bf8afc2f (patch) | |
tree | b9afc12290390ca539fd91c78dc54c1fed33c39a | |
parent | 856ab90ca8cf6ace5528396049d53e302d1a3ebe (diff) | |
download | tor-4a497e503077826228df667083548d06bf8afc2f.tar.gz tor-4a497e503077826228df667083548d06bf8afc2f.zip |
if our clock jumps forward by 100 seconds or more, assume something
has gone wrong with our network and abandon all not-yet-used circs.
svn:r3792
-rw-r--r-- | src/or/circuitbuild.c | 6 | ||||
-rw-r--r-- | src/or/circuitlist.c | 13 | ||||
-rw-r--r-- | src/or/main.c | 4 | ||||
-rw-r--r-- | src/or/or.h | 2 |
4 files changed, 24 insertions, 1 deletions
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c index 2c9542e99c..4862442678 100644 --- a/src/or/circuitbuild.c +++ b/src/or/circuitbuild.c @@ -469,6 +469,12 @@ int circuit_send_next_onion_skin(circuit_t *circ) { return 0; } +void circuit_note_clock_jumped(int seconds_elapsed) { + log_fn(LOG_NOTICE,"Your clock just jumped %d seconds forward; assuming established circuits no longer work.", seconds_elapsed); + has_completed_circuit=0; /* so it'll log when it works again */ + circuit_mark_all_unused_circs(); +} + /** Take the 'extend' cell, pull out addr/port plus the onion skin. Make * sure we're connected to the next hop, and pass it the onion skin in * a create cell. diff --git a/src/or/circuitlist.c b/src/or/circuitlist.c index 6f812cb6b1..2c5c300e3e 100644 --- a/src/or/circuitlist.c +++ b/src/or/circuitlist.c @@ -359,6 +359,19 @@ circuit_get_clean_open(uint8_t purpose, int need_uptime, return best; } +/** Go through the circuitlist; mark-for-close each circuit that starts + * at us but has not yet been used. */ +void circuit_mark_all_unused_circs(void) { + circuit_t *circ; + + for (circ=global_circuitlist; circ; circ = circ->next) { + if (CIRCUIT_IS_ORIGIN(circ) && + !circ->marked_for_close && + !circ->timestamp_dirty) + circuit_mark_for_close(circ); + } +} + /** Mark <b>circ</b> to be closed next time we call * circuit_close_all_marked(). Do any cleanup needed: * - If state is onionskin_pending, remove circ from the onion_pending diff --git a/src/or/main.c b/src/or/main.c index 4ebace81f1..a167e20412 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -892,8 +892,10 @@ static void second_elapsed_callback(int fd, short event, void *args) stats_prev_global_write_bucket = global_write_bucket; /* if more than 10s have elapsed, probably the clock jumped: doesn't count. */ - if (seconds_elapsed < 10) + if (seconds_elapsed < 100) stats_n_seconds_working += seconds_elapsed; + else + circuit_note_clock_jumped(seconds_elapsed); assert_all_pending_dns_resolves_ok(); run_scheduled_events(now.tv_sec); diff --git a/src/or/or.h b/src/or/or.h index 0a8d6610f4..1991d7fcf5 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -1124,6 +1124,7 @@ circuit_t *circuit_establish_circuit(uint8_t purpose, const char *exit_digest, int need_uptime, int need_capacity, int internal); void circuit_n_conn_done(connection_t *or_conn, int status); int circuit_send_next_onion_skin(circuit_t *circ); +void circuit_note_clock_jumped(int seconds_elapsed); int circuit_extend(cell_t *cell, circuit_t *circ); int circuit_init_cpath_crypto(crypt_path_t *cpath, char *key_data, int reverse); int circuit_finish_handshake(circuit_t *circ, char *reply); @@ -1149,6 +1150,7 @@ circuit_t *circuit_get_next_by_pk_and_purpose(circuit_t *start, circuit_t *circuit_get_rendezvous(const char *cookie); circuit_t *circuit_get_clean_open(uint8_t purpose, int need_uptime, int need_capacity, int internal); +void circuit_mark_all_unused_circs(void); int _circuit_mark_for_close(circuit_t *circ); #define circuit_mark_for_close(c) \ |