[or-cvs] if >=2 circs are being built that handle a given stream,

Roger Dingledine arma at seul.org
Fri Dec 12 23:03:27 UTC 2003


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

Modified Files:
	circuit.c onion.c or.h routerlist.c 
Log Message:
if >=2 circs are being built that handle a given stream,
no need to have new circs handle it too.


Index: circuit.c
===================================================================
RCS file: /home/or/cvsroot/src/or/circuit.c,v
retrieving revision 1.112
retrieving revision 1.113
diff -u -d -r1.112 -r1.113
--- circuit.c	9 Dec 2003 02:06:58 -0000	1.112
+++ circuit.c	12 Dec 2003 23:03:25 -0000	1.113
@@ -275,6 +275,26 @@
   return num;
 }
 
+#define MIN_CIRCUITS_HANDLING_STREAM 2
+/* return 1 if at least MIN_CIRCUITS_HANDLING_STREAM non-open circuits
+ * will have an acceptable exit node for conn. Else return 0.
+ */
+int circuit_stream_is_being_handled(connection_t *conn) {
+  circuit_t *circ;
+  routerinfo_t *exitrouter;
+  int num=0;
+
+  for(circ=global_circuitlist;circ;circ = circ->next) {
+    if(circ->cpath && circ->state != CIRCUIT_STATE_OPEN) {
+      exitrouter = router_get_by_nickname(circ->build_state->chosen_exit);
+      if(exitrouter && connection_ap_can_use_exit(conn, exitrouter) >= 0)
+        if(++num >= MIN_CIRCUITS_HANDLING_STREAM)
+          return 1;
+    }
+  }
+  return 0;
+}
+
 int circuit_deliver_relay_cell(cell_t *cell, circuit_t *circ,
                                int cell_direction, crypt_path_t *layer_hint) {
   connection_t *conn=NULL;

Index: onion.c
===================================================================
RCS file: /home/or/cvsroot/src/or/onion.c,v
retrieving revision 1.104
retrieving revision 1.105
diff -u -d -r1.104 -r1.105
--- onion.c	9 Dec 2003 01:04:40 -0000	1.104
+++ onion.c	12 Dec 2003 23:03:25 -0000	1.105
@@ -233,7 +233,8 @@
   for (i = 0; i < n_connections; ++i) {
     if (carray[i]->type == CONN_TYPE_AP &&
         carray[i]->state == AP_CONN_STATE_CIRCUIT_WAIT &&
-        !carray[i]->marked_for_close)
+        !carray[i]->marked_for_close &&
+        !circuit_stream_is_being_handled(carray[i]))
       ++n_pending_connections;
   }
   log_fn(LOG_DEBUG, "Choosing exit node; %d connections are pending",
@@ -265,7 +266,8 @@
     for (j = 0; j < n_connections; ++j) { /* iterate over connections */
       if (carray[j]->type != CONN_TYPE_AP ||
           carray[j]->state != AP_CONN_STATE_CIRCUIT_WAIT ||
-          carray[j]->marked_for_close)
+          carray[j]->marked_for_close ||
+          circuit_stream_is_being_handled(carray[j]))
         continue; /* Skip everything but APs in CIRCUIT_WAIT */
       switch (connection_ap_can_use_exit(carray[j], dir->routers[i])) 
         {

Index: or.h
===================================================================
RCS file: /home/or/cvsroot/src/or/or.h,v
retrieving revision 1.200
retrieving revision 1.201
diff -u -d -r1.200 -r1.201
--- or.h	8 Dec 2003 23:45:36 -0000	1.200
+++ or.h	12 Dec 2003 23:03:25 -0000	1.201
@@ -517,6 +517,7 @@
 
 void circuit_expire_building(void);
 int circuit_count_building(void);
+int circuit_stream_is_being_handled(connection_t *conn);
 
 int circuit_deliver_relay_cell(cell_t *cell, circuit_t *circ,
                                int cell_direction, crypt_path_t *layer_hint);

Index: routerlist.c
===================================================================
RCS file: /home/or/cvsroot/src/or/routerlist.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- routerlist.c	9 Dec 2003 04:29:52 -0000	1.4
+++ routerlist.c	12 Dec 2003 23:03:25 -0000	1.5
@@ -698,7 +698,7 @@
 
 
 /* Helper function: reads a single router entry from *s, and advances
- * updates *s so it points to just after the router it just read.
+ * *s so it points to just after the router it just read.
  * mallocs a new router and returns it if all goes well, else returns
  * NULL.
  */



More information about the tor-commits mailing list