aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2006-10-01 06:41:13 +0000
committerRoger Dingledine <arma@torproject.org>2006-10-01 06:41:13 +0000
commit4096e577c51a6eae88ab26cb4931998b0486e678 (patch)
treefa01f2a89a28aab3ef1828604e33b012a04d6db7 /src
parent96a4cb1dfa4d65c6c57261f038aa5bdf6e776ac2 (diff)
downloadtor-4096e577c51a6eae88ab26cb4931998b0486e678.tar
tor-4096e577c51a6eae88ab26cb4931998b0486e678.tar.gz
if we fail to build a circuit to an intended enclave, and it's
not mandatory that we use that enclave, stop wanting it. svn:r8559
Diffstat (limited to 'src')
-rw-r--r--src/or/circuituse.c5
-rw-r--r--src/or/connection_edge.c35
-rw-r--r--src/or/or.h1
-rw-r--r--src/or/relay.c6
4 files changed, 44 insertions, 3 deletions
diff --git a/src/or/circuituse.c b/src/or/circuituse.c
index 06e093690..4ccd4c1be 100644
--- a/src/or/circuituse.c
+++ b/src/or/circuituse.c
@@ -748,6 +748,11 @@ circuit_build_failed(origin_circuit_t *circ)
case CIRCUIT_PURPOSE_C_GENERAL:
/* If we never built the circuit, note it as a failure. */
circuit_increment_failure_count();
+ if (failed_at_last_hop) {
+ /* Make sure any streams that demand our last hop as their exit
+ * know that it's unlikely to happen. */
+ circuit_discard_optional_exit_enclaves(circ->cpath->prev->extend_info);
+ }
break;
case CIRCUIT_PURPOSE_TESTING:
circuit_testing_failed(circ, failed_at_last_hop);
diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c
index 2814108d9..c02999aff 100644
--- a/src/or/connection_edge.c
+++ b/src/or/connection_edge.c
@@ -453,6 +453,41 @@ connection_ap_attach_pending(void)
}
}
+/** 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.
+ */
+void
+circuit_discard_optional_exit_enclaves(extend_info_t *info)
+{
+ connection_t **carray;
+ connection_t *conn;
+ edge_connection_t *edge_conn;
+ routerinfo_t *r1, *r2;
+ int n, i;
+
+ get_connection_array(&carray, &n);
+
+ for (i = 0; i < n; ++i) {
+ conn = carray[i];
+ if (conn->marked_for_close ||
+ conn->type != CONN_TYPE_AP ||
+ !conn->chosen_exit_optional)
+ continue;
+ edge_conn = TO_EDGE_CONN(conn);
+ r1 = router_get_by_nickname(edge_conn->chosen_exit_name, 0);
+ r2 = router_get_by_nickname(info->nickname, 0);
+ if (r1 && r2 && r1==r2) {
+ tor_assert(edge_conn->socks_request);
+ log_info(LD_APP, "Giving up on enclave exit '%s' for destination %s.",
+ safe_str(edge_conn->chosen_exit_name),
+ escaped_safe_str(edge_conn->socks_request->address));
+ conn->chosen_exit_optional = 0;
+ tor_free(edge_conn->chosen_exit_name); /* clears it */
+ }
+ }
+}
+
/** The AP connection <b>conn</b> has just failed while attaching or
* sending a BEGIN or resolving on <b>circ</b>, but another circuit
* might work. Detach the circuit, and either reattach it, launch a
diff --git a/src/or/or.h b/src/or/or.h
index e6ea1b104..0cce2b592 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -1936,6 +1936,7 @@ int connection_edge_is_rendezvous_stream(edge_connection_t *conn);
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 circuit_discard_optional_exit_enclaves(extend_info_t *info);
int connection_ap_detach_retriable(edge_connection_t *conn,
origin_circuit_t *circ);
diff --git a/src/or/relay.c b/src/or/relay.c
index 631f0e9d6..36cff7129 100644
--- a/src/or/relay.c
+++ b/src/or/relay.c
@@ -721,7 +721,7 @@ connection_edge_process_end_not_open(
if (conn->_base.chosen_exit_optional) {
/* stop wanting a specific exit */
conn->_base.chosen_exit_optional = 0;
- tor_free(conn->chosen_exit_name);
+ tor_free(conn->chosen_exit_name); /* clears it */
}
if (connection_ap_detach_retriable(conn, circ) >= 0)
return 0;
@@ -745,7 +745,7 @@ connection_edge_process_end_not_open(
if (conn->_base.chosen_exit_optional) {
/* stop wanting a specific exit */
conn->_base.chosen_exit_optional = 0;
- tor_free(conn->chosen_exit_name);
+ tor_free(conn->chosen_exit_name); /* clears it */
}
if (connection_ap_detach_retriable(conn, circ) >= 0)
return 0;
@@ -770,7 +770,7 @@ connection_edge_process_end_not_open(
if (conn->_base.chosen_exit_optional) {
/* stop wanting a specific exit */
conn->_base.chosen_exit_optional = 0;
- tor_free(conn->chosen_exit_name);
+ tor_free(conn->chosen_exit_name); /* clears it */
}
if (connection_ap_detach_retriable(conn, circ) >= 0)
return 0;