backport r14162-r14164

svn:r14167
This commit is contained in:
Roger Dingledine 2008-03-24 19:14:48 +00:00
parent ef551d7d26
commit 981ad6021d
4 changed files with 46 additions and 1 deletions

View File

@ -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,

View File

@ -210,15 +210,22 @@ circuit_expire_building(time_t now)
{
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 @@ circuit_build_failed(origin_circuit_t *circ)
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);
}
}

View File

@ -457,6 +457,32 @@ connection_ap_attach_pending(void)
});
}
/** 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.

View File

@ -2801,6 +2801,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 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,