aboutsummaryrefslogtreecommitdiff
path: root/src/or/connection_edge.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2012-12-25 23:30:28 -0500
committerNick Mathewson <nickm@torproject.org>2012-12-25 23:30:28 -0500
commit885e8d35c7af65b3e1e598d6f2e951ba84e65928 (patch)
tree8babd1d1ce290fd98d43cc948a90001a05ca5c93 /src/or/connection_edge.c
parent265aab298ad923425e136013f6c439b5fba32558 (diff)
parent406d59a9c93e46bcb5be0e0a5c087f4860522d56 (diff)
downloadtor-885e8d35c7af65b3e1e598d6f2e951ba84e65928.tar.gz
tor-885e8d35c7af65b3e1e598d6f2e951ba84e65928.zip
Merge remote-tracking branch 'mikeperry/209-path-bias-changes'
Diffstat (limited to 'src/or/connection_edge.c')
-rw-r--r--src/or/connection_edge.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c
index 28c9e09ee5..a7c201fcf1 100644
--- a/src/or/connection_edge.c
+++ b/src/or/connection_edge.c
@@ -2186,6 +2186,27 @@ connection_ap_handshake_socks_reply(entry_connection_t *conn, char *reply,
status==SOCKS5_SUCCEEDED ? STREAM_EVENT_SUCCEEDED : STREAM_EVENT_FAILED,
endreason);
+ /* Flag this stream's circuit as having completed a stream successfully
+ * (for path bias) */
+ if (status == SOCKS5_SUCCEEDED ||
+ endreason == END_STREAM_REASON_RESOLVEFAILED ||
+ endreason == END_STREAM_REASON_CONNECTREFUSED ||
+ endreason == END_STREAM_REASON_CONNRESET ||
+ endreason == END_STREAM_REASON_NOROUTE ||
+ endreason == END_STREAM_REASON_RESOURCELIMIT) {
+ if (!conn->edge_.on_circuit ||
+ !CIRCUIT_IS_ORIGIN(conn->edge_.on_circuit)) {
+ // DNS remaps can trigger this. So can failed hidden service
+ // lookups.
+ log_info(LD_BUG,
+ "No origin circuit for successful SOCKS stream %lu. Reason: "
+ "%d", ENTRY_TO_CONN(conn)->global_identifier, endreason);
+ } else {
+ TO_ORIGIN_CIRCUIT(conn->edge_.on_circuit)->path_state
+ = PATH_STATE_USE_SUCCEEDED;
+ }
+ }
+
if (conn->socks_request->has_finished) {
log_warn(LD_BUG, "(Harmless.) duplicate calls to "
"connection_ap_handshake_socks_reply.");
@@ -2453,6 +2474,10 @@ connection_exit_begin_conn(cell_t *cell, circuit_t *circ)
assert_circuit_ok(circ);
connection_exit_connect(n_stream);
+
+ /* For path bias: This circuit was used successfully */
+ origin_circ->path_state = PATH_STATE_USE_SUCCEEDED;
+
tor_free(address);
return 0;
}