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

[or-cvs] r14167: backport r14162-r14164 (in tor/branches/tor-0_2_0-patches: . src/or)



Author: arma
Date: 2008-03-24 15:14:48 -0400 (Mon, 24 Mar 2008)
New Revision: 14167

Modified:
   tor/branches/tor-0_2_0-patches/ChangeLog
   tor/branches/tor-0_2_0-patches/src/or/circuituse.c
   tor/branches/tor-0_2_0-patches/src/or/connection_edge.c
   tor/branches/tor-0_2_0-patches/src/or/or.h
Log:
backport r14162-r14164


Modified: tor/branches/tor-0_2_0-patches/ChangeLog
===================================================================
--- tor/branches/tor-0_2_0-patches/ChangeLog	2008-03-24 18:43:01 UTC (rev 14166)
+++ tor/branches/tor-0_2_0-patches/ChangeLog	2008-03-24 19:14:48 UTC (rev 14167)
@@ -1,3 +1,11 @@
+Changes in version 0.2.0.23-rc - 2008-03-2?
+  o Major bugfixes:
+    - When a tunneled directory request is made to a directory server
+      that's down, notice after 30 seconds rather than 120 seconds. Also,
+      fail any begindir streams that are pending on it, so they can
+      retry elsewhere. This was causing multi-minute delays on bootstrap.
+
+
 Changes in version 0.2.0.22-rc - 2008-03-18
   o Major features:
     - Enable encrypted directory connections by default for non-relays,

Modified: tor/branches/tor-0_2_0-patches/src/or/circuituse.c
===================================================================
--- tor/branches/tor-0_2_0-patches/src/or/circuituse.c	2008-03-24 18:43:01 UTC (rev 14166)
+++ tor/branches/tor-0_2_0-patches/src/or/circuituse.c	2008-03-24 19:14:48 UTC (rev 14167)
@@ -210,15 +210,22 @@
 {
   circuit_t *victim, *circ = global_circuitlist;
   time_t cutoff = now - get_options()->CircuitBuildTimeout;
+  time_t begindir_cutoff = now - get_options()->CircuitBuildTimeout/2;
+  cpath_build_state_t *build_state;
 
   while (circ) {
     victim = circ;
     circ = circ->next;
     if (!CIRCUIT_IS_ORIGIN(victim) || /* didn't originate here */
-        victim->timestamp_created > cutoff || /* Not old enough to expire */
         victim->marked_for_close) /* don't mess with marked circs */
       continue;
 
+    build_state = TO_ORIGIN_CIRCUIT(victim)->build_state;
+    if (victim->timestamp_created >
+        ((build_state && build_state->onehop_tunnel) ?
+         begindir_cutoff : cutoff))
+      continue; /* it's still young, leave it alone */
+
 #if 0
     /* some debug logs, to help track bugs */
     if (victim->purpose >= CIRCUIT_PURPOSE_C_INTRODUCING &&
@@ -738,6 +745,9 @@
       n_conn->_base.or_is_obsolete = 1;
       entry_guard_register_connect_status(n_conn->identity_digest, 0,
                                           time(NULL));
+      /* if there are any one-hop streams waiting on this circuit, fail
+       * them now so they can retry elsewhere. */
+      connection_ap_fail_onehop(n_conn->identity_digest);
     }
   }
 

Modified: tor/branches/tor-0_2_0-patches/src/or/connection_edge.c
===================================================================
--- tor/branches/tor-0_2_0-patches/src/or/connection_edge.c	2008-03-24 18:43:01 UTC (rev 14166)
+++ tor/branches/tor-0_2_0-patches/src/or/connection_edge.c	2008-03-24 19:14:48 UTC (rev 14167)
@@ -457,6 +457,32 @@
   });
 }
 
+/** Tell any AP streams that are waiting for a onehop tunnel to
+ * <b>failed_digest</b> that they are going to fail. */
+void
+connection_ap_fail_onehop(const char *failed_digest)
+{
+  edge_connection_t *edge_conn;
+  char digest[DIGEST_LEN];
+  smartlist_t *conns = get_connection_array();
+  SMARTLIST_FOREACH(conns, connection_t *, conn,
+  {
+    if (conn->marked_for_close ||
+        conn->type != CONN_TYPE_AP ||
+        conn->state != AP_CONN_STATE_CIRCUIT_WAIT)
+      continue;
+    edge_conn = TO_EDGE_CONN(conn);
+    if (!edge_conn->want_onehop)
+      continue;
+    if (!hexdigest_to_digest(edge_conn->chosen_exit_name, digest) &&
+        !memcmp(digest, failed_digest, DIGEST_LEN)) {
+      log_info(LD_APP, "Closing onehop stream to '%s' because the OR conn "
+                       "just failed.", edge_conn->chosen_exit_name);
+      connection_mark_unattached_ap(edge_conn, END_STREAM_REASON_TIMEOUT);
+    }
+  });
+}
+
 /** A circuit failed to finish on its last hop <b>info</b>. If there
  * are any streams waiting with this exit node in mind, but they
  * don't absolutely require it, make them give up on it.

Modified: tor/branches/tor-0_2_0-patches/src/or/or.h
===================================================================
--- tor/branches/tor-0_2_0-patches/src/or/or.h	2008-03-24 18:43:01 UTC (rev 14166)
+++ tor/branches/tor-0_2_0-patches/src/or/or.h	2008-03-24 19:14:48 UTC (rev 14167)
@@ -2801,6 +2801,7 @@
 int connection_ap_can_use_exit(edge_connection_t *conn, routerinfo_t *exit);
 void connection_ap_expire_beginning(void);
 void connection_ap_attach_pending(void);
+void connection_ap_fail_onehop(const char *failed_digest);
 void circuit_discard_optional_exit_enclaves(extend_info_t *info);
 int connection_ap_detach_retriable(edge_connection_t *conn,
                                    origin_circuit_t *circ,