[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] clean up and refactor some more



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

Modified Files:
	circuitbuild.c circuitlist.c circuituse.c or.h rendclient.c 
Log Message:
clean up and refactor some more


Index: circuitbuild.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/circuitbuild.c,v
retrieving revision 1.90
retrieving revision 1.91
diff -u -d -r1.90 -r1.91
--- circuitbuild.c	22 Mar 2005 00:42:38 -0000	1.90
+++ circuitbuild.c	22 Mar 2005 01:01:15 -0000	1.91
@@ -246,7 +246,7 @@
   return 0; /* if r == 1 */
 }
 
-/** Create and return new circuit. Initialize its purpose and
+/** Create and return a new circuit. Initialize its purpose and
  * build-state based on our arguments. */
 circuit_t *
 circuit_init(uint8_t purpose, int need_uptime, int need_capacity, int internal) {
@@ -1168,8 +1168,9 @@
   return 0;
 }
 
-/** Take the open circ originating here, give it a new exit destination
- * to <b>exit</b>, and get it to send the next extend cell.
+/** Give <b>circ</b> a new exit destination to <b>exit</b>, and add a
+ * hop to the cpath reflecting this. Don't send the next extend cell --
+ * the caller will do this if it wants to.
  */
 int
 circuit_append_new_exit(circuit_t *circ, routerinfo_t *exit) {
@@ -1183,6 +1184,22 @@
   return 0;
 }
 
+/** Take the open circ originating here, give it a new exit destination
+ * to <b>exit</b>, and get it to send the next extend cell. If you can't
+ * send the extend cell, mark the circuit for close and return -1, else
+ * return 0. */
+int circuit_extend_to_new_exit(circuit_t *circ, routerinfo_t *exit) {
+  circuit_append_new_exit(circ, exit);
+  circ->state = CIRCUIT_STATE_BUILDING;
+  if (circuit_send_next_onion_skin(circ)<0) {
+    log_fn(LOG_WARN, "Couldn't extend circuit to new point '%s'.",
+           circ->build_state->chosen_exit_name);
+    circuit_mark_for_close(circ);
+    return -1;
+  }
+  return 0;
+}
+
 /** Return the number of routers in <b>routers</b> that are currently up
  * and available for building circuits through.
  */

Index: circuitlist.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/circuitlist.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- circuitlist.c	22 Mar 2005 00:42:38 -0000	1.31
+++ circuitlist.c	22 Mar 2005 01:01:15 -0000	1.32
@@ -77,7 +77,7 @@
 circuit_t *circuit_new(uint16_t p_circ_id, connection_t *p_conn) {
   circuit_t *circ;
   static uint32_t n_circuits_allocated = 1;
-    /* never zero, since a global ID of 0 treated specially by the controller */
+    /* never zero, since a global ID of 0 is treated specially by the controller */
 
   circ = tor_malloc_zero(sizeof(circuit_t));
   circ->magic = CIRCUIT_MAGIC;

Index: circuituse.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/circuituse.c,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -d -r1.58 -r1.59
--- circuituse.c	22 Mar 2005 00:42:38 -0000	1.58
+++ circuituse.c	22 Mar 2005 01:01:15 -0000	1.59
@@ -722,14 +722,8 @@
         case CIRCUIT_PURPOSE_S_CONNECT_REND:
           /* need to add a new hop */
           tor_assert(exit);
-          circuit_append_new_exit(circ, exit);
-          circ->state = CIRCUIT_STATE_BUILDING;
-          if (circuit_send_next_onion_skin(circ)<0) {
-            log_fn(LOG_WARN, "Couldn't extend circuit to new point '%s'.",
-                   circ->build_state->chosen_exit_name);
-            circuit_mark_for_close(circ);
+          if (circuit_extend_to_new_exit(circ, exit) < 0)
             return NULL;
-          }
           break;
         default:
           log_fn(LOG_WARN,"Bug: unexpected purpose %d when cannibalizing a general circ.",

Index: or.h
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/or.h,v
retrieving revision 1.563
retrieving revision 1.564
diff -u -d -r1.563 -r1.564
--- or.h	22 Mar 2005 00:42:38 -0000	1.563
+++ or.h	22 Mar 2005 01:01:15 -0000	1.564
@@ -1137,6 +1137,7 @@
                                         int *need_capacity);
 
 int circuit_append_new_exit(circuit_t *circ, routerinfo_t *exit);
+int circuit_extend_to_new_exit(circuit_t *circ, routerinfo_t *exit);
 void onion_append_to_cpath(crypt_path_t **head_ptr, crypt_path_t *new_hop);
 
 /********************************* circuitlist.c ***********************/

Index: rendclient.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/rendclient.c,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -d -r1.77 -r1.78
--- rendclient.c	22 Mar 2005 00:42:38 -0000	1.77
+++ rendclient.c	22 Mar 2005 01:01:15 -0000	1.78
@@ -226,14 +226,7 @@
       log_fn(LOG_INFO, "Chose new intro point %s for %s (circ %d)",
              nickname, circ->rend_query, circ->n_circ_id);
       tor_free(nickname);
-      circuit_append_new_exit(circ, r);
-      circ->state = CIRCUIT_STATE_BUILDING;
-      if (circuit_send_next_onion_skin(circ)<0) {
-        log_fn(LOG_WARN, "Couldn't extend circuit to new point '%s'.",
-               circ->build_state->chosen_exit_name);
-        circuit_mark_for_close(circ);
-        return -1;
-      }
+      return circuit_extend_to_new_exit(circ, r);
     }
   }
   return 0;