summaryrefslogtreecommitdiff
path: root/src/or/circuituse.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2005-03-12 04:22:01 +0000
committerNick Mathewson <nickm@torproject.org>2005-03-12 04:22:01 +0000
commit115271f65e1b84cea09f0fb401afb123f22b075b (patch)
treeab148aad2c1d2f5e320011b8507507817e48c918 /src/or/circuituse.c
parentd1f790e9cec42783e47805a8593ca5532a525904 (diff)
downloadtor-115271f65e1b84cea09f0fb401afb123f22b075b.tar.gz
tor-115271f65e1b84cea09f0fb401afb123f22b075b.zip
Implement the common case of ATTACHSTREAM.
svn:r3751
Diffstat (limited to 'src/or/circuituse.c')
-rw-r--r--src/or/circuituse.c49
1 files changed, 33 insertions, 16 deletions
diff --git a/src/or/circuituse.c b/src/or/circuituse.c
index 076c0a6548..fafeadcd10 100644
--- a/src/or/circuituse.c
+++ b/src/or/circuituse.c
@@ -980,6 +980,36 @@ consider_recording_trackhost(connection_t *conn, circuit_t *circ) {
time(NULL) + options->TrackHostExitsExpire);
}
+/* DOCDOC. Return as for connection_ap_handshake_attach_chosen_circuit. */
+int
+connection_ap_handshake_attach_chosen_circuit(connection_t *conn,
+ circuit_t *circ)
+{
+ tor_assert(conn);
+ tor_assert(conn->type == CONN_TYPE_AP);
+ tor_assert(conn->state == AP_CONN_STATE_CIRCUIT_WAIT ||
+ conn->state == AP_CONN_STATE_CONTROLLER_WAIT);
+ tor_assert(conn->socks_request);
+ tor_assert(circ);
+
+ conn->state = AP_CONN_STATE_CIRCUIT_WAIT;
+
+ if (!circ->timestamp_dirty)
+ circ->timestamp_dirty = time(NULL);
+
+ link_apconn_to_circ(conn, circ);
+ tor_assert(conn->socks_request);
+ if (conn->socks_request->command == SOCKS_COMMAND_CONNECT) {
+ consider_recording_trackhost(conn, circ);
+ connection_ap_handshake_send_begin(conn, circ);
+ } else {
+ connection_ap_handshake_send_resolve(conn, circ);
+ }
+
+ return 1;
+}
+
+
/** Try to find a safe live circuit for CONN_TYPE_AP connection conn. If
* we don't find one: if conn cannot be handled by any known nodes,
* warn and return -1 (conn needs to die);
@@ -1024,27 +1054,14 @@ int connection_ap_handshake_attach_circuit(connection_t *conn) {
if (retval < 1)
return retval;
- /* We have found a suitable circuit for our conn. Hurray. */
- tor_assert(circ);
-
- log_fn(LOG_DEBUG,"Attaching apconn to general circ %d (stream %d sec old).",
+ log_fn(LOG_DEBUG,"Attaching apconn to circ %d (stream %d sec old).",
circ->n_circ_id, conn_age);
/* here, print the circ's path. so people can figure out which circs are sucking. */
circuit_log_path(LOG_INFO,circ);
- if (!circ->timestamp_dirty)
- circ->timestamp_dirty = time(NULL);
-
- link_apconn_to_circ(conn, circ);
- tor_assert(conn->socks_request);
- if (conn->socks_request->command == SOCKS_COMMAND_CONNECT) {
- consider_recording_trackhost(conn, circ);
- connection_ap_handshake_send_begin(conn, circ);
- } else {
- connection_ap_handshake_send_resolve(conn, circ);
- }
+ /* We have found a suitable circuit for our conn. Hurray. */
+ return connection_ap_handshake_attach_chosen_circuit(conn, circ);
- return 1;
} else { /* we're a rendezvous conn */
circuit_t *rendcirc=NULL, *introcirc=NULL;