[or-cvs] be more aggressive about trying to make circuits:

Roger Dingledine arma at seul.org
Wed Aug 18 08:51:08 UTC 2004


Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/home2/arma/work/onion/cvs/src/or

Modified Files:
	circuitbuild.c circuituse.c or.h 
Log Message:
be more aggressive about trying to make circuits:
try once a second for 30 seconds, and only when the entire previous
period has failed do we pause after MAX_CIRCUIT_FAILURES failures.


Index: circuitbuild.c
===================================================================
RCS file: /home/or/cvsroot/src/or/circuitbuild.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- circuitbuild.c	18 Aug 2004 06:10:12 -0000	1.27
+++ circuitbuild.c	18 Aug 2004 08:51:04 -0000	1.28
@@ -386,7 +386,7 @@
       /* done building the circuit. whew. */
       circ->state = CIRCUIT_STATE_OPEN;
       log_fn(LOG_INFO,"circuit built!");
-      circuit_reset_failure_count();
+      circuit_reset_failure_count(0);
       if(!has_completed_circuit) {
         has_completed_circuit=1;
         log_fn(LOG_NOTICE,"Tor has successfully opened a circuit. Looks like it's working.");

Index: circuituse.c
===================================================================
RCS file: /home/or/cvsroot/src/or/circuituse.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- circuituse.c	18 Aug 2004 06:47:01 -0000	1.9
+++ circuituse.c	18 Aug 2004 08:51:04 -0000	1.10
@@ -298,7 +298,7 @@
   circ = circuit_get_youngest_clean_open(CIRCUIT_PURPOSE_C_GENERAL);
 
   if(time_to_new_circuit < now) {
-    circuit_reset_failure_count();
+    circuit_reset_failure_count(1);
     time_to_new_circuit = now + options.NewCircuitPeriod;
     if(proxy_mode())
       client_dns_clean();
@@ -585,6 +585,7 @@
  * circuit_launch_new and circuit_*_failure_count.
  */
 static int n_circuit_failures = 0;
+static int did_circs_fail_last_period = 0;
 
 /** Don't retry launching a new circuit if we try this many times with no
  * success. */
@@ -597,7 +598,8 @@
     return NULL;
   }
 
-  if (n_circuit_failures > MAX_CIRCUIT_FAILURES) {
+  if (did_circs_fail_last_period &&
+      n_circuit_failures > MAX_CIRCUIT_FAILURES) {
     /* too many failed circs in a row. don't try. */
 //    log_fn(LOG_INFO,"%d failures so far, not trying.",n_circuit_failures);
     return NULL;
@@ -635,7 +637,11 @@
  * we will try MAX_CIRCUIT_FAILURES times more (if necessary) before
  * stopping again.
  */
-void circuit_reset_failure_count(void) {
+void circuit_reset_failure_count(int timeout) {
+  if(timeout && n_circuit_failures > MAX_CIRCUIT_FAILURES)
+    did_circs_fail_last_period = 1;
+  else
+    did_circs_fail_last_period = 0;
   n_circuit_failures = 0;
 }
 

Index: or.h
===================================================================
RCS file: /home/or/cvsroot/src/or/or.h,v
retrieving revision 1.411
retrieving revision 1.412
diff -u -d -r1.411 -r1.412
--- or.h	18 Aug 2004 06:10:12 -0000	1.411
+++ or.h	18 Aug 2004 08:51:04 -0000	1.412
@@ -1003,7 +1003,7 @@
 void circuit_build_failed(circuit_t *circ);
 circuit_t *circuit_launch_by_nickname(uint8_t purpose, const char *exit_nickname);
 circuit_t *circuit_launch_by_identity(uint8_t purpose, const char *exit_digest);
-void circuit_reset_failure_count(void);
+void circuit_reset_failure_count(int timeout);
 int connection_ap_handshake_attach_circuit(connection_t *conn);
 
 int circuit_init_cpath_crypto(crypt_path_t *cpath, char *key_data,int reverse);



More information about the tor-commits mailing list