[or-cvs] Carefully increment failure counts when appropriate

Nick Mathewson nickm at seul.org
Wed Apr 7 20:59:40 UTC 2004


Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/tmp/cvs-serv1373/src/or

Modified Files:
	circuit.c 
Log Message:
Carefully increment failure counts when appropriate

Index: circuit.c
===================================================================
RCS file: /home/or/cvsroot/src/or/circuit.c,v
retrieving revision 1.193
retrieving revision 1.194
diff -u -d -r1.193 -r1.194
--- circuit.c	7 Apr 2004 20:38:23 -0000	1.193
+++ circuit.c	7 Apr 2004 20:59:38 -0000	1.194
@@ -14,7 +14,7 @@
 static void circuit_rep_hist_note_result(circuit_t *circ);
 
 static void circuit_is_open(circuit_t *circ);
-static void circuit_failed(circuit_t *circ);
+static void circuit_build_failed(circuit_t *circ);
 static circuit_t *circuit_establish_circuit(uint8_t purpose, const char *exit_nickname);
 
 unsigned long stats_n_relay_cells_relayed = 0;
@@ -854,7 +854,7 @@
    * links worked and which didn't.
    */
   if (circ->state != CIRCUIT_STATE_OPEN) {
-    circuit_failed(circ); /* take actions if necessary */
+    circuit_build_failed(circ); /* take actions if necessary */
     circuit_rep_hist_note_result(circ);
   }
 
@@ -1130,7 +1130,9 @@
   }
 }
 
-static void circuit_failed(circuit_t *circ) {
+/* Called whenever a circuit could not be successfully built.
+ */
+static void circuit_build_failed(circuit_t *circ) {
 
   /* we should examine circ and see if it failed because of
    * the last hop or an earlier hop. then use this info below.
@@ -1148,23 +1150,37 @@
       break;
     case CIRCUIT_PURPOSE_S_ESTABLISH_INTRO:
       /* at Bob, waiting for introductions */
+      if (circ->state != CIRCUIT_STATE_OPEN) {
+        circuit_increment_failure_count();
+      }
       /* no need to care here, because bob will rebuild intro
        * points periodically. */
       break;
     case CIRCUIT_PURPOSE_C_INTRODUCING:
       /* at Alice, connecting to intro point */
+      /* Don't increment failure count, since Bob may have picked
+       * the inttroduction point badly */
       /* Alice will pick a new intro point when this one dies, if
        * the stream in question still cares. No need to act here. */
       break;
     case CIRCUIT_PURPOSE_C_ESTABLISH_REND:
       /* at Alice, waiting for Bob */
+      if (circ->state != CIRCUIT_STATE_OPEN) {
+        circuit_increment_failure_count();
+      }
       /* Alice will pick a new rend point when this one dies, if
        * the stream in question still cares. No need to act here. */
       break;
     case CIRCUIT_PURPOSE_S_CONNECT_REND:
       /* at Bob, connecting to rend point */
+      /* Don't increment failure count, since Alice may have picked
+       * the rendezvous point badly */
       log_fn(LOG_INFO,"Couldn't connect to Alice's chosen rend point %s. Sucks to be Alice.", circ->build_state->chosen_exit);
       break;
+    default:
+      /* Other cases are impossible, since this function is only caused with
+       * unbuilt circuits. */
+      assert(0);
   }
 }
 



More information about the tor-commits mailing list