]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
if our clock jumps forward by 100 seconds or more, assume something
authorRoger Dingledine <arma@torproject.org>
Sat, 19 Mar 2005 23:58:42 +0000 (23:58 +0000)
committerRoger Dingledine <arma@torproject.org>
Sat, 19 Mar 2005 23:58:42 +0000 (23:58 +0000)
has gone wrong with our network and abandon all not-yet-used circs.

svn:r3792

src/or/circuitbuild.c
src/or/circuitlist.c
src/or/main.c
src/or/or.h

index 2c9542e99c8079bf3ffdf238786f7994f5acdaf3..4862442678f366b2dec4bd5a165245a2b164e385 100644 (file)
@@ -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.
index 6f812cb6b1296772c35867a0a28698b6bf598bc5..2c5c300e3e5ccca25d9061b0b068fecddf8a9763 100644 (file)
@@ -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
index 4ebace81f1fb5f1af52b0a2a5e1fdbf59a4a8efb..a167e204128d42a367938126edab326dc9d01b6c 100644 (file)
@@ -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);
index 0a8d6610f444329da62bd1f1cb330b26e129a90d..1991d7fcf57b0026ec1c1a3e20ba6f8c19aa44a7 100644 (file)
@@ -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)                                       \