aboutsummaryrefslogtreecommitdiff
path: root/src/or/connection_edge.c
diff options
context:
space:
mode:
authorMike Perry <mikeperry-git@fscked.org>2013-01-30 21:27:38 -0400
committerNick Mathewson <nickm@torproject.org>2013-02-01 17:01:16 -0500
commitbce6714f99df6fd00c90918ac0a7407bf1f764e3 (patch)
treeb879f615aeb6e4d5f8583bba3afc49026f75463e /src/or/connection_edge.c
parent3a63e5ef4237464d6f499b271414ee4071856fe8 (diff)
downloadtor-bce6714f99df6fd00c90918ac0a7407bf1f764e3.tar.gz
tor-bce6714f99df6fd00c90918ac0a7407bf1f764e3.zip
Refactor code that rolls back the use state
Also document it better. Mention this refactoring in the comments for the path state machine.
Diffstat (limited to 'src/or/connection_edge.c')
-rw-r--r--src/or/connection_edge.c25
1 files changed, 7 insertions, 18 deletions
diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c
index 9e2c15d2ca..b4fa3e6fe2 100644
--- a/src/or/connection_edge.c
+++ b/src/or/connection_edge.c
@@ -637,21 +637,15 @@ connection_ap_expire_beginning(void)
}
if (circ->purpose == CIRCUIT_PURPOSE_C_REND_JOINED) {
if (seconds_idle >= options->SocksTimeout) {
- /* Path bias: We need to probe the circuit to ensure validity.
- * Roll its state back if it succeeded so that we do so upon close. */
- if (TO_ORIGIN_CIRCUIT(circ)->path_state == PATH_STATE_USE_SUCCEEDED) {
- log_info(LD_CIRC,
- "Rolling back pathbias use state to 'attempted' for timed "
- "out rend circ %d",
- TO_ORIGIN_CIRCUIT(circ)->global_identifier);
- TO_ORIGIN_CIRCUIT(circ)->path_state = PATH_STATE_USE_ATTEMPTED;
- }
-
log_fn(severity, LD_REND,
"Rend stream is %d seconds late. Giving up on address"
" '%s.onion'.",
seconds_idle,
safe_str_client(entry_conn->socks_request->address));
+ /* Roll back path bias use state so that we probe the circuit
+ * if nothing else succeeds on it */
+ pathbias_mark_use_rollback(TO_ORIGIN_CIRCUIT(circ));
+
connection_edge_end(conn, END_STREAM_REASON_TIMEOUT);
connection_mark_unattached_ap(entry_conn, END_STREAM_REASON_TIMEOUT);
}
@@ -816,14 +810,9 @@ connection_ap_detach_retriable(entry_connection_t *conn,
control_event_stream_status(conn, STREAM_EVENT_FAILED_RETRIABLE, reason);
ENTRY_TO_CONN(conn)->timestamp_lastread = time(NULL);
- /* Path bias: We need to probe the circuit to ensure validity.
- * Roll its state back if it succeeded so that we do so upon close. */
- if (circ->path_state == PATH_STATE_USE_SUCCEEDED) {
- log_info(LD_CIRC,
- "Rolling back pathbias use state to 'attempted' for detached "
- "circuit %d", circ->global_identifier);
- circ->path_state = PATH_STATE_USE_ATTEMPTED;
- }
+ /* Roll back path bias use state so that we probe the circuit
+ * if nothing else succeeds on it */
+ pathbias_mark_use_rollback(circ);
if (conn->pending_optimistic_data) {
generic_buffer_set_to_copy(&conn->sending_optimistic_data,