[or-cvs] r14163: when our onehop circuits were failing, nobody was telling th (tor/trunk/src/or)

arma at seul.org arma at seul.org
Mon Mar 24 05:48:52 UTC 2008


Author: arma
Date: 2008-03-24 01:48:51 -0400 (Mon, 24 Mar 2008)
New Revision: 14163

Modified:
   tor/trunk/src/or/circuituse.c
   tor/trunk/src/or/connection_edge.c
   tor/trunk/src/or/or.h
Log:
when our onehop circuits were failing, nobody was telling the
streams. so they waited 120 seconds before timing out. this
was particularly bad during bootstrapping, if an authority is
down or not answering right.


Modified: tor/trunk/src/or/circuituse.c
===================================================================
--- tor/trunk/src/or/circuituse.c	2008-03-24 03:50:21 UTC (rev 14162)
+++ tor/trunk/src/or/circuituse.c	2008-03-24 05:48:51 UTC (rev 14163)
@@ -744,6 +744,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/trunk/src/or/connection_edge.c
===================================================================
--- tor/trunk/src/or/connection_edge.c	2008-03-24 03:50:21 UTC (rev 14162)
+++ tor/trunk/src/or/connection_edge.c	2008-03-24 05:48:51 UTC (rev 14163)
@@ -460,6 +460,35 @@
   });
 }
 
+/** Tell any AP streams that are waiting for a onehop tunnel to
+ * <b>failed_digest</b> that they are going to fail. */
+/* XXX021 We should get rid of this function, and instead attach
+ * onehop streams to circ->p_streams so they get marked in
+ * circuit_mark_for_close like normal p_streams. */
+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/trunk/src/or/or.h
===================================================================
--- tor/trunk/src/or/or.h	2008-03-24 03:50:21 UTC (rev 14162)
+++ tor/trunk/src/or/or.h	2008-03-24 05:48:51 UTC (rev 14163)
@@ -2812,6 +2812,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,



More information about the tor-commits mailing list