[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r8559: if we fail to build a circuit to an intended enclave, and it (tor/trunk/src/or)
- To: or-cvs@xxxxxxxxxxxxx
- Subject: [or-cvs] r8559: if we fail to build a circuit to an intended enclave, and it (tor/trunk/src/or)
- From: arma@xxxxxxxx
- Date: Sun, 1 Oct 2006 02:41:14 -0400 (EDT)
- Delivered-to: archiver@seul.org
- Delivered-to: or-cvs-outgoing@seul.org
- Delivered-to: or-cvs@seul.org
- Delivery-date: Sun, 01 Oct 2006 02:41:21 -0400
- Reply-to: or-talk@xxxxxxxxxxxxx
- Sender: owner-or-cvs@xxxxxxxxxxxxx
Author: arma
Date: 2006-10-01 02:41:13 -0400 (Sun, 01 Oct 2006)
New Revision: 8559
Modified:
tor/trunk/src/or/circuituse.c
tor/trunk/src/or/connection_edge.c
tor/trunk/src/or/or.h
tor/trunk/src/or/relay.c
Log:
if we fail to build a circuit to an intended enclave, and it's
not mandatory that we use that enclave, stop wanting it.
Modified: tor/trunk/src/or/circuituse.c
===================================================================
--- tor/trunk/src/or/circuituse.c 2006-10-01 04:55:12 UTC (rev 8558)
+++ tor/trunk/src/or/circuituse.c 2006-10-01 06:41:13 UTC (rev 8559)
@@ -748,6 +748,11 @@
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);
Modified: tor/trunk/src/or/connection_edge.c
===================================================================
--- tor/trunk/src/or/connection_edge.c 2006-10-01 04:55:12 UTC (rev 8558)
+++ tor/trunk/src/or/connection_edge.c 2006-10-01 06:41:13 UTC (rev 8559)
@@ -453,6 +453,41 @@
}
}
+/** 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
Modified: tor/trunk/src/or/or.h
===================================================================
--- tor/trunk/src/or/or.h 2006-10-01 04:55:12 UTC (rev 8558)
+++ tor/trunk/src/or/or.h 2006-10-01 06:41:13 UTC (rev 8559)
@@ -1936,6 +1936,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 circuit_discard_optional_exit_enclaves(extend_info_t *info);
int connection_ap_detach_retriable(edge_connection_t *conn,
origin_circuit_t *circ);
Modified: tor/trunk/src/or/relay.c
===================================================================
--- tor/trunk/src/or/relay.c 2006-10-01 04:55:12 UTC (rev 8558)
+++ tor/trunk/src/or/relay.c 2006-10-01 06:41:13 UTC (rev 8559)
@@ -721,7 +721,7 @@
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 @@
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 @@
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;