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

[or-cvs] r16581: {tor} Open two client introduction circuits simultaneously. With m (tor/branches/hidserv-perf/src/or)



Author: chrisw
Date: 2008-08-18 02:33:54 -0400 (Mon, 18 Aug 2008)
New Revision: 16581

Modified:
   tor/branches/hidserv-perf/src/or/circuituse.c
Log:
Open two client introduction circuits simultaneously. With minor issues.

Modified: tor/branches/hidserv-perf/src/or/circuituse.c
===================================================================
--- tor/branches/hidserv-perf/src/or/circuituse.c	2008-08-17 21:49:50 UTC (rev 16580)
+++ tor/branches/hidserv-perf/src/or/circuituse.c	2008-08-18 06:33:54 UTC (rev 16581)
@@ -445,8 +445,8 @@
   /* Fourth, see if we need any more hidden service (client) circuits. */
   if (rep_hist_get_predicted_internal(now, &hidserv_needs_uptime,
                                       &hidserv_needs_capacity) &&
-      ((num_uptime_internal<2 && hidserv_needs_uptime) ||
-        num_internal<2)) {
+      ((num_uptime_internal<3 && hidserv_needs_uptime) ||
+        num_internal<3)) {
     if (hidserv_needs_uptime)
       flags |= CIRCLAUNCH_NEED_UPTIME;
     if (hidserv_needs_capacity)
@@ -694,8 +694,27 @@
       connection_ap_attach_pending();
       break;
     case CIRCUIT_PURPOSE_C_INTRODUCING:
-      rend_client_introcirc_has_opened(circ);
-      break;
+        log_info(LD_GENERAL,
+      	       "TWOINTRO circ purpose %d", circ->_base.purpose);
+        /* TWOINTRO Check whether another introcirc was already opened 
+         * for this hidden service request */
+        if (TO_CIRCUIT(circ)->introcirc_for_edge_connection->
+            introcirc_already_open == 0) {
+            
+        	log_info(LD_GENERAL, "TWOINTRO First intro circ candidate %s "
+        			 "opened for service %s", circ->cpath->extend_info->nickname, TO_CIRCUIT(circ)->
+            		 introcirc_for_edge_connection->rend_query);
+                   	
+        	TO_CIRCUIT(circ)->introcirc_for_edge_connection->
+                              introcirc_already_open = 1;
+        	rend_client_introcirc_has_opened(circ);
+        } else{
+            log_info(LD_GENERAL, "TWOINTRO Second intro circ candidate %s for "
+            		 "service %s opened", circ->cpath->extend_info->nickname, TO_CIRCUIT(circ)->
+            		 introcirc_for_edge_connection->rend_query); 
+        	
+        }
+        break;
     case CIRCUIT_PURPOSE_C_GENERAL:
       /* Tell any AP connections that have been waiting for a new
        * circuit that one is ready. */
@@ -1039,11 +1058,19 @@
     log_debug(LD_CIRC, "one on the way!");
   if (!circ) {
     extend_info_t *extend_info=NULL;
+    extend_info_t *extend_info2=NULL;
     uint8_t new_circ_purpose;
+    origin_circuit_t *circ2=NULL;
 
     if (desired_circuit_purpose == CIRCUIT_PURPOSE_C_INTRODUCE_ACK_WAIT) {
       /* need to pick an intro point */
       extend_info = rend_client_get_random_intro(conn->rend_query);
+//      while (!strcmp(extend_info2->identity_digest, 
+//    		        extend_info->identity_digest)) {
+        extend_info2 = rend_client_get_random_intro(conn->rend_query);
+//      }
+
+      /* TWOINTRO Select second intro point and fetch info, if neccessary */
       if (!extend_info) {
         log_info(LD_REND,
                  "No intro points for '%s': refetching service descriptor.",
@@ -1053,8 +1080,9 @@
         conn->_base.state = AP_CONN_STATE_RENDDESC_WAIT;
         return 0;
       }
-      log_info(LD_REND,"Chose '%s' as intro point for '%s'.",
-               extend_info->nickname, safe_str(conn->rend_query));
+      log_info(LD_REND,"Chose '%s' and '%s' as intro points for '%s'.",
+               extend_info->nickname, extend_info2->nickname, 
+               safe_str(conn->rend_query));
     }
 
     /* If we have specified a particular exit node for our
@@ -1119,10 +1147,24 @@
       if (need_internal) flags |= CIRCLAUNCH_IS_INTERNAL;
       circ = circuit_launch_by_extend_info(new_circ_purpose, extend_info,
                                            flags);
+
+      if (new_circ_purpose == CIRCUIT_PURPOSE_C_INTRODUCING) {
+        /* TWOINTRO Launch second circuit, if neccessary */
+        circ2 = circuit_launch_by_extend_info(new_circ_purpose, extend_info2,
+                                               flags);
+        strlcpy(circ2->rend_query, conn->rend_query, sizeof(circ2->rend_query));
+        /* TWOINTRO Mark both circuits as introcirc candidates */
+    	TO_CIRCUIT(circ)->introcirc_for_edge_connection = conn;
+    	TO_CIRCUIT(circ2)->introcirc_for_edge_connection = conn;
+    	conn->introcirc_already_open = 0;
+      }
     }
 
     if (extend_info)
       extend_info_free(extend_info);
+    
+    if (extend_info2)
+      extend_info_free(extend_info2);
 
     if (desired_circuit_purpose != CIRCUIT_PURPOSE_C_GENERAL) {
       /* help predict this next time */