[or-cvs] Let resolve conns retry/expire also, rather than sticking a...

Roger Dingledine arma at seul.org
Tue Nov 30 08:39:17 UTC 2004


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

Modified Files:
	circuituse.c connection_edge.c main.c 
Log Message:
Let resolve conns retry/expire also, rather than sticking around forever.

Put the check-if-requested-exitrouter-will-reject-us code in the
circuit_attach loop, so it gets checked periodically and not just
once at the beginning. This is useful in case the routerlist changes,
but also in case the address gets resolved into something that we learn
we'll reject.


Index: circuituse.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/circuituse.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- circuituse.c	30 Nov 2004 02:26:41 -0000	1.30
+++ circuituse.c	30 Nov 2004 08:39:14 -0000	1.31
@@ -794,6 +794,20 @@
   if (!connection_edge_is_rendezvous_stream(conn)) { /* we're a general conn */
     circuit_t *circ=NULL;
 
+    if (conn->chosen_exit_name) {
+      routerinfo_t *router = router_get_by_nickname(conn->chosen_exit_name);
+      if(!router) {
+        log_fn(LOG_WARN,"Requested exit point '%s' is not known. Closing.",
+               conn->chosen_exit_name);
+        return -1;
+      }
+      if (!connection_ap_can_use_exit(conn, router)) {
+        log_fn(LOG_WARN, "Requested exit point '%s' would refuse request. Closing.",
+               conn->chosen_exit_name);
+        return -1;
+      }
+    }
+
     /* find the circuit that we should use, if there is one. */
     retval = circuit_get_open_circ_or_launch(conn, CIRCUIT_PURPOSE_C_GENERAL, &circ);
     if (retval < 1)

Index: connection_edge.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/connection_edge.c,v
retrieving revision 1.249
retrieving revision 1.250
diff -u -d -r1.249 -r1.250
--- connection_edge.c	30 Nov 2004 08:15:09 -0000	1.249
+++ connection_edge.c	30 Nov 2004 08:39:14 -0000	1.250
@@ -233,8 +233,8 @@
  */
 #define MAX_STREAM_RETRIES 4
 
-/** Find all general-purpose AP streams in state connect_wait that sent
- * their begin cell >=15 seconds ago. Detach from their current circuit,
+/** Find all general-purpose AP streams waiting for a response that sent
+ * their begin/resolve cell >=15 seconds ago. Detach from their current circuit,
  * and mark their current circuit as unsuitable for new streams. Then call
  * connection_ap_handshake_attach_circuit() to attach to a new circuit (if
  * available) or launch a new one.
@@ -254,7 +254,9 @@
 
   for (i = 0; i < n; ++i) {
     conn = carray[i];
-    if (conn->type != CONN_TYPE_AP ||
+    if (conn->type != CONN_TYPE_AP)
+      continue;
+    if (conn->state != AP_CONN_STATE_RESOLVE_WAIT &&
         conn->state != AP_CONN_STATE_CONNECT_WAIT)
       continue;
     if (now - conn->timestamp_lastread < 15)
@@ -262,7 +264,7 @@
     conn->num_retries++;
     circ = circuit_get_by_conn(conn);
     if (!circ) { /* it's vanished? */
-      log_fn(LOG_INFO,"Conn is in connect-wait, but lost its circ.");
+      log_fn(LOG_INFO,"Conn is waiting, but lost its circ.");
       connection_mark_for_close(conn);
       continue;
     }
@@ -278,12 +280,12 @@
     tor_assert(circ->purpose == CIRCUIT_PURPOSE_C_GENERAL);
     if (conn->num_retries >= MAX_STREAM_RETRIES) {
       log_fn(LOG_WARN,"Stream is %d seconds late. Giving up.",
-             15*conn->num_retries);
+             15*conn->num_retries); /* XXX this number is not accurate */
       circuit_log_path(LOG_WARN, circ);
       connection_edge_end(conn, END_STREAM_REASON_TIMEOUT, conn->cpath_layer);
       connection_mark_for_close(conn);
     } else {
-      log_fn(LOG_WARN,"Stream is %d seconds late. Retrying.",
+      log_fn(LOG_NOTICE,"Stream is %d seconds late. Retrying.",
              (int)(now - conn->timestamp_lastread));
       circuit_log_path(LOG_WARN, circ);
       /* send an end down the circuit */
@@ -354,7 +356,6 @@
   socks_request_t *socks;
   int sockshere;
   hostname_type_t addresstype;
-  routerinfo_t *router;
 
   tor_assert(conn);
   tor_assert(conn->type == CONN_TYPE_AP);
@@ -414,17 +415,6 @@
     }
     conn->chosen_exit_name = tor_strdup(s+1);
     *s = 0;
-    router = router_get_by_nickname(conn->chosen_exit_name);
-    if(!router) {
-      log_fn(LOG_WARN,"Requested exit point '%s' is not known. Closing.",
-             conn->chosen_exit_name);
-      return -1;
-    }
-    if (!connection_ap_can_use_exit(conn, router)) {
-      log_fn(LOG_WARN, "Requested exit point '%s' would refuse request. Closing.",
-             conn->chosen_exit_name);
-      return -1;
-    }
   }
 
   if (addresstype != ONION_HOSTNAME) {

Index: main.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/main.c,v
retrieving revision 1.397
retrieving revision 1.398
diff -u -d -r1.397 -r1.398
--- main.c	29 Nov 2004 22:25:30 -0000	1.397
+++ main.c	30 Nov 2004 08:39:14 -0000	1.398
@@ -565,7 +565,7 @@
     }
     last_rotated_certificate = now;
     /* XXXX We should rotate TLS connections as well; this code doesn't change
-     * XXXX them at all. */
+     *      them at all. */
   }
 
   /** 1c. If we have to change the accounting interval or record



More information about the tor-commits mailing list